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
SAS Super FREQ
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]

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!

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.

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