DATA Step, Macro, Functions and more

SAS Macro to parse data by frequency - inexperienced user

Reply
N/A
Posts: 0

SAS Macro to parse data by frequency - inexperienced user

Good morning all,

Let me start out by letting you know that my SAS experience is minimal at best. So I need some help altering a macro written a few years ago by someone who left my firm long before I started.

Over the past few years we've been running a job (posted below) that takes one somewhat large data file (haver.sas) and parses it into three files based on the frequencies of the data in the file (i.e. it creates three new SAS files - one for annual data, one for quarterly, and one for monthly).

I've gotten a request to add weekly and daily data to the original haver.sas file. So I need to alter the SAS job to also parse and create new files for these data.

My first (and really only) thought was to just add two lines of code at the bottom, which were %process(weekly) and %process(daily). This did not work at all, and in fact caused the whole job to stop working altogether. So after restoring the affected folders back to the day before I started messing with them, I'm back to square one.

Any and all thoughts would be greatly appreciated! And here is the code:

options nocenter;
/*... HAVER.sas is copied from g:\deptdata\research\haver\haver.sas .*/
filename haver 'g:\deptdata\research\Haver\dbupd\sashaver\haver.sas';
/*... sas is a directory containing SAS data sets ..................*/
libname sas 'g:\deptdata\research\Haver\dbupd\sashaver\saslibrary';
%macro process(frequency);
%*==> This section creates SAS data sets from the Haver data ...........;
proc datasource filetype=haver
infile=haver
interval=&frequency
out=sas.&frequency;
run;
%mend;
%process(annual)
%process(quarterly)
%process(monthly)
Frequent Contributor
Posts: 82

Re: SAS Macro to parse data by frequency - inexperience user

Posted in reply to deleted_user
Have never used this procedure, but if no other ideas, check:

http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/etsug_datasrc_sect006.htm

So it could be
%process (week);
%process (day);

But it is only a guess, so hopefully somebody with more experience will answer.

Good luck with your work!
Trusted Advisor
Posts: 2,116

Re: SAS Macro to parse data by frequency - inexperienced user

Posted in reply to deleted_user
According to the documentation for DATASOURCE, the weekly and daily data are not available for a file from Haver Analytics:

http://support.sas.com/documentation/cdl/en/etsug/60372/HTML/default/etsug_datasrc_sect051.htm
N/A
Posts: 0

Re: SAS Macro to parse data by frequency - inexperienced user

Interesting, thanks for the info. I will check with Haver and see what they suggest.
N/A
Posts: 0

Re: SAS Macro to parse data by frequency - inexperienced user

Posted in reply to deleted_user
Well Haver was no help. I tried altering the code from a macro using 'datasource' to using the SASEHAVR engine but that didn't work either.

Maybe someone out there happens to work with Haver and can help. If not, thanks to those who responded and at least pointed me in the right direction.
N/A
Posts: 0

Re: SAS Macro to parse data by frequency - inexperienced user

Posted in reply to deleted_user
Going in a new direction. Instead of lumping the daily and quarterly data in with the rest, I am creating them separately. This creates simple haverd.sas and haverw.sas files.

Is there a simple SAS program I can run that will read these in and spit them out/save them as .sas7bdat files? Stat/Transfer won't read the simple .sas files.

I'm covering as much ground in the support area myself, not just looking for someone to do my job for me, but I admit being given the code would be faster.

Thanks!
Ask a Question
Discussion stats
  • 5 replies
  • 154 views
  • 0 likes
  • 3 in conversation