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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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