BookmarkSubscribeRSS Feed
David_Billa
Rhodochrosite | Level 12

Appericiate if someone of you help me understand this query.

 

proc sql;
select W5XZP9G.COL1  *  CRE.Factor from work.W5XZP9G as W5XZP9G,IFEXT.CRE as CRE;
quit;
2 REPLIES 2
ed_sas_member
Meteorite | Level 14

Hi @David_Billa,

 

In my understanding, you have two datasets:

- W5XZP9G in the WORK library, which is identified as "W5XZP9G" (cf. alias keyword AS in the FROM clause)

- CRE in the IFEXT, which is identified as "CRE"

 

The query creates all Cartesian products resulting from the combination of these datasets as the type of join (e.g. inner, left, right or full) is not specified.

 

So the query results in the display of all possible combinations of the multiplication of the variable COL1 in the dataset W5XZP9G and the variable Factor in the dataset CRE.

 

Example:

data work.have1;
	input col1;
	datalines;
2
5
;
run;
data work.have2;
	input Factor;
	datalines;
2
5
;
run;

proc sql;
	select W5XZP9G.COL1,
		   CRE.Factor,
		   W5XZP9G.COL1  *  CRE.Factor
	from work.have1 as W5XZP9G, work.have2 as CRE;
quit;

Output:

Capture d’écran 2020-04-12 à 09.21.43.png

Hope this helps.

Best,

ChrisNZ
Tourmaline | Level 20

Just format the code properly and suddenly it's legible.

proc sql;
  select W5XZP9G.COL1 * CRE.Factor 
  from WORK.W5XZP9G as W5XZP9G
      ,IFEXT.CRE    as CRE;
quit;

There is not excuse ever for not formatting code to be as pretty as possible.

Align things, add spaces. That's all.

Pretty means legible means easy to avoid and to identify bugs.

 

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 350 views
  • 1 like
  • 3 in conversation