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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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