BookmarkSubscribeRSS Feed
Perscat1
Calcite | Level 5

I have a query which creates a report  for a specified order number as follows

 

proc sql;

Select orderid, productid,orderdate,linetotal

From Salesorders

where orderid = 'A1234'

quit;

 

Now I have a list of order IDs in a dataset from here:

Select orderid from JulySales

 

I would like to create a report like the first query but for every orderid in the second query. 

Any help is greatly appreciated.

 

2 REPLIES 2
SASKiwi
PROC Star

How about just one report grouped by ORDERID like this?

proc sort data = JulySales;
  by orderid;
run;

proc print data = JulySales;
  by orderid;
  id oderid;
run;
FM_MF
Calcite | Level 5

You can correct it as follows:

proc sql;
 select orderid, productid,orderdate,linetotal
 from Salesorders
 where orderid in (select orderid from JulySales);
quit;

But you should first ensure that the attributes(length, format etc) of orderID in dataset-JulySales and dataset-Salessorders are same.

 

Hope this helps.

 

Thanks,

Fred

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 16. 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
  • 427 views
  • 5 likes
  • 3 in conversation