BookmarkSubscribeRSS Feed
MARS
Calcite | Level 5
Hi

Actually I want to sub set my data with the following program

data final.abc;
set abc;
where date = '30Dec2010" d and customerNo in (select custno. from salesdata);
run;

data set abc and and data set salesdata both exist in as a temporary data set.
I want to sub set the data not only by date (a variable in dataset abc) but also by CustomerNo( also a variable in data set abc) by setting its value equal to Custno. ( a variable in another dataset salesdata).

Can somebody please check the syntax for sas, as I am unable to run this command.

regards
Mars
3 REPLIES 3
Paige
Quartz | Level 8
SELECT clause will not work in a Data step.

If you want to use the SELECT clause, you have to do this in PROC SQL.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
The SAS PROC SQL documentation has examples for generating a macro variable data-string for a WHERE IN () as you have suggested.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

generate where statement in string using proc sql select into site:sas.com
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Mars,

You need something like this:
[pre]
proc SQL;
create table final.abc as
select a.*,b.* /* list all variables you need from two datasets */
from abc as a, salesdata as b
where a.date='30Dec2010'd and a.customerNo=b.Custno
;quit;
[/pre]
Sincerely,
SPR

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 3 replies
  • 3411 views
  • 0 likes
  • 4 in conversation