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 ; )
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" ;
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?
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...
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.
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.
Ready to level-up your skills? Choose your own adventure.