BookmarkSubscribeRSS Feed
ren2010
Obsidian | Level 7
Hi All,

I have a file which has date fields(data is in text format eg:'20090112')
for eg fromdate1,fromdate2,fromdate3, thrudate1 thrudate2 thrudate3.
I wanted to run a proc freq on these date fileds,is it possible to include the proc freq in a do loop with in a macro?

Thanks in advance.
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Sure, you use DICTIONARY.COLUMNS with PROC SQL to generate a list of the macro variables you want to process, and within a SAS macro, you iterate through the macro variable list through substituting each variable on the TABLES statement.

There are references in the archives as well as topic-related reference papers / material available at the SAS support http://support.sas.com/ website.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

repetitive code dictionary columns site:sas.com
Cynthia_sas
Diamond | Level 26
Hi:
Another possibility. Let's say you have a dataset called WORK.MYDATA, then you could do this...without needing a macro program. Because you are using the colon modifier to keep any variable that starts "fromdate" or "thrudate" (assuming they are character variables), then using the _character_ special variable reference will ONLY have proc freq create one table for each variable -- fromdate1 through fromdaten, and thrudate1 through thrudaten, etc.

cynthia
[pre]

proc freq data=work.mydata(keep=fromdate: thrudate:);
tables _character_;
run;
[/pre]

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 1819 views
  • 0 likes
  • 3 in conversation