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.

 

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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