Understanding Intersect Operator in Data Analysis

the intersect operator n.w
1 / 9
Embed
Share

Learn about how the INTERSECT operator selects common unique rows from both result sets in data analysis. See examples of flow diagrams and SQL queries using the INTERSECT operator, and discover its applications in combining and analyzing data sets effectively.

  • Data Analysis
  • INTERSECT Operator
  • SQL Queries
  • Data Sets
  • Flow Diagrams

Uploaded on | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. The INTERSECT Operator Common unique rows from both result sets are selected. 1

  2. Flow Diagram: INTERSECT Operator INTERSECT Yes CORR Remove nonmatching columns. No ALL No Yes Remove duplicate rows. Save matching rows. End 2

  3. data data t1(drop=i) t2(drop=i rename=(z=w)); call streaminit(13453 13453); do i= 1 1 to 3 3; x=int(rand("uniform")*5 5); z=int(rand("uniform")*5 5); output t1; output t2; end; do i= 4 4 to 6 6; x=int(rand("uniform")*5 5); z=int(rand("uniform")*5 5); output t1; x=int(rand("uniform")*5 5); z=int(rand("uniform")*5 5); output t2; end; run run; data data t1; set t1 end=done; output; if done then output; run run; data data t2; set t2 end=done; output; if _n_=1 1 then output; run run; Example Data Sets title "t1"; proc proc print print data=t1 noobs;run title "t2"; proc proc print print data=t2 noobs;run title; run; run; 3

  4. proc proc sql quit quit; sql; select * select * from t2 ; from t1 intersect

  5. proc proc sql quit quit; sql; select * select * from t2 ; from t1 intersect corr 5

  6. proc proc sql quit quit; sql; select * select * from t2 ; from t1 intersect all 6

  7. Orion Star frequently hires experienced Sales staff at higher levels on the assumption that they will be more productive than inexperienced personnel. Create a report that displays the employee identification number of current Level III and Level IV Sales staff hired in 2004, who made at least one sale by the end of 2005. orion.Order_fact table contains information on all sales. orion.Salestable contains information about current Sales employees, including job titles and hire dates. 7

  8. The INTERSECT Operator Need a query that returns information from rows that exist in both orion.Sales and orion.Order_fact. sales by Sales staff 8

  9. Create a report that displays the employee identification number of current Level III and Level IV Sales staff hired in 2004, who made at least one sale by the end of 2005. proc proc sql select Employee_ID from orion.Sales where year(Hire_date)=2004 and scan(Job_Title,-1 1) in ("III","IV") intersect all select distinct Employee_ID from orion.Order_fact where year(Order_date) le 2005 quit quit; sql; 2004 2005; 9

Related


More Related Content