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

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

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 4053 views
  • 0 likes
  • 4 in conversation