DATA Step, Macro, Functions and more

Repeating a process for each dataset identified

Accepted Solution Solved
Reply
Contributor
Posts: 54
Accepted Solution

Repeating a process for each dataset identified

[ Edited ]

Firstly thanks for all answers. iam a new student of sas programming.and want to ask a problem. I have a dataset named as 'tables' and contents 4 rows:
Tables
-----------
Orion
Clinics
Datas
Other
;

I want to do a loop. Firstly read dataset name "orion" then go to work.orion dataset and calculate something...etc. Then go to second dataset "clinics" and again calculate sth. And goes on like this. i couldnt do that. If dataset names used to be like table1 table2 table3 i can do it with macros, %do i=1 %to n.... But i couldnt succeeded with it different dataset names.thanks again


Accepted Solutions
Solution
‎02-21-2017 10:36 AM
Super User
Posts: 5,513

Re: Repeating a process for each dataset identified

Since you would know how to do this if the data sets were named differently, here's a link that might help:

 

http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-pe...

 

 

View solution in original post


All Replies
Super User
Posts: 19,822

Re: Repeating a process for each dataset identified

[ Edited ]

The solution for this would look like:

1. Make a macro, as you've indicated that takes a single parameter - dataset name. 

2. Use call execute to call macro for each dataset. 

 

It it sounds like you're having issues with step 1? 

Solution
‎02-21-2017 10:36 AM
Super User
Posts: 5,513

Re: Repeating a process for each dataset identified

Since you would know how to do this if the data sets were named differently, here's a link that might help:

 

http://blogs.sas.com/content/sastraining/2015/01/30/sas-authors-tip-getting-the-macro-language-to-pe...

 

 

Contributor
Posts: 54

Re: Repeating a process for each dataset identified

Dear Reeza i work in a bank. And i have 60 different datasets each one has 120 columns and 16 gb.i want to get some info from each one. Datasets has unique transactions.I dont want to write 60 different macro. Dear astounding i didnt understand from blog page. Can you send me a code which is runned. Thanks
Super User
Posts: 5,513

Re: Repeating a process for each dataset identified

No, I don't have any secrets above and beyond what was in that paper.

 

You had indicated that you knew how accomplish this task if the data set names were table1, table2, table3, etc.  This paper just shows  you have to do the same thing if the table names don't have a pattern to them.  Are you stuck on how to get a list of the data set names?

Super User
Posts: 19,822

Re: Repeating a process for each dataset identified


Yavuz wrote:
Can you send me a code which is runned. 

No. You haven't specified what you need to get working at all. 

Here's a basic tutorial on Macro's but does a good job of going through what you likely need.

 

http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/

 

If you're looking for more resources I highly suggest searching lexjansen.com

 

 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 209 views
  • 2 likes
  • 3 in conversation