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...
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.