BookmarkSubscribeRSS Feed
pdhokriya
Pyrite | Level 9

How to read and manipulate multiple dataset from 1 library

 

Ex.

- datasets in work library has 4datasets (one two three four)

- want to add condition on each datasets ( like if stutus = "Y" then output ; )

 

4 REPLIES 4
Tom
Super User Tom
Super User

What are you going to read the datasets with?  A procedure, like PROC MEANS?  A data step?

If a data step do you need to read all of them together?  How do you want to combine them?  What output dataset(s) are you creating?

 

Sounds like you just want to use a WHERE statement.

where status = "Y" ;
pdhokriya
Pyrite | Level 9
Yes I want too read and create all the datasets at a time.

where considtion I understood.
Kurt_Bremser
Super User

If I understand you correctly, you have X number of datasets, and after the task have the same X number of datasets, but with reduced observations because of the applied WHERE?

Reeza
Super User

When you want to do the same thing multiple times in SAS look at either BY group processing or macro with loops or call execute.

 

UCLA introductory tutorial on macro variables and macros

https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/

Tutorial on converting a working program to a macro

This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md

Examples of common macro usage

https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...

SAS Innovate 2025: Register Today!

 

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 4 replies
  • 1104 views
  • 1 like
  • 4 in conversation