BookmarkSubscribeRSS Feed
pdhokriya
Pyrite | Level 9

Hi ,

 

how to apply where condition ( same condition ) when there are multiple ( apprx 30 - 100) datasets (dataset names and count is unknown ) in 1 library.

 

I have do this manually, but this is not feasible when there are multiple datasets in 1 library.

 

how do i short this code?

 

Also I want same naming covension for input dataset and output datasets. like one and one.

 

data one;
input name $ var1 ;
cards;
A 100
B 200
C 300
;
run;

data two;
input name $ var1 ;
cards;
A 100
B 200
D 300
;
run;

data three;
input name $ var1 ;
cards;
A 100
F 300
D 300
;
run;

data four;
input name $ var1 ;
cards;
A 100
F 300
D 300
G 300
;
run;

 

 

data one ; set one; if var1 = 300 then delete; run;

data two ; set two; if var1 = 300 then delete; run;

data three ; set three; if var1 = 300 then delete; run;

data four ; set four; if var1 = 300 then delete; run;

 

 

 

 

1 REPLY 1
sbxkoenk
SAS Super FREQ

hello @pdhokriya ,

 

Use data-driven code generation with file-put-include!
Other techniques are also possible (call execute, macro, ...).

PROC SQL noprint;
 create table work.tables as
 select memname
 from dictionary.tables
; QUIT;

/* suppose above query results in below data set */
data work.tables;
LENGTH memname $ 32;
memname='one';   output;
memname='two';   output;
memname='three'; output;
memname='four';  output;
run;

filename tt temp;

data _NULL_;
 set work.tables;
 file tt;
PUT 'data ' memname '; set ' memname '; if var1 = 300 then delete; run;';
run;

/* proc fslist file=tt; run; */
options source2;
%INCLUDE tt;
/* end of program */

Cheers,

Koen

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!
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
  • 1 reply
  • 849 views
  • 0 likes
  • 2 in conversation