LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 13 Jun 2006 01:38:27 -0400
Reply-To:     Joe Whitehurst <joewhitehurst@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Whitehurst <joewhitehurst@GMAIL.COM>
Subject:      Re: Need advice on using a macro inside a data step array loop
              please.
Comments: To: Peter Constantinidis <peter@constantinidis.ca>
In-Reply-To:  <7ffd0c20606121735y4347cff2kc2bc6e63fb3d6dfa@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Peter,

Noting that you are a fast learner, I feel almost obligated to tell you that SAS Component Language will allow you to do, functionally, exactly what you want to do the way you want to do it without any worries about step boundaries, quoting/masking etc.--steps, in the traditional sense are not required in SCL . If you have sufficient mastery of SAS Data Step programming to start playing with macros, you already know 95% of SAS Component Language code needed to place the Macro Language and its limitations behind you. Do almost exactly what you used to do with the macro language except do it with a language exactly like the Data Step Language (no %s and few &s) instead of such Rube Goldbergish programming construct as the SAS Macro Array. Spend a few hours reading about SAS Component Language LISTS and the carefully designed 28 functions for manipulating data in SCL LISTs and then think about what is missing in the Rube Goldberg contraption construct. I don't know how fast, fast is from your point of view, but if you could report back to the list by Friday with a succinct comparison I would think that was damn fast.

Joe

On 6/12/06, Peter Constantinidis <peter@constantinidis.ca> wrote: > > This is actually my first time trying macros and arrays out but I'm a > fast learner, and you guys telling me what ends up happening is you > get a data inside a data step, that's an eye opener. The papers I read > didn't caution about that happening. > > Here is the complete code of the test program, and why I used 3 > positional calls all the same, because originally the code was the > same block of code my boss wrote repeated 50 times with just those 3 > names changed. > > *** A macro containing code chunk to export to a dat file ***; > > %macro csvtodat(fieldname,datasetname,filename); > > LIBNAME perm 'G:\DSU\CRITERIA\EE Datasets'; *folder to store sas > datasets permanently; > > > data WORK.temp; > %let _EFIERR_ = 0; /* set the ERROR detection macro variable */ > infile 'C:\recruits\season\&filename.csv' delimiter = ',' > MISSOVER DSD lrecl=32767 firstobs=2 ; > > informat VAR1 $150. ; > informat VAR2 $20. ; > informat VAR3 $18. ; > informat VAR4 $9. ; > informat VAR5 $16. ; > informat VAR6 $1. ; > informat VAR7 $3. ; > informat VAR8 $4. ; > informat VAR9 $1. ; > informat VAR10 $24. ; > informat VAR11 $1. ; > informat VAR12 $7. ; > informat VAR13 $16. ; > informat VAR14 $3. ; > informat VAR15 $4. ; > informat VAR16 $33. ; > informat VAR17 $7. ; > informat VAR18 $16. ; > informat VAR19 $3. ; > informat VAR20 $4. ; > informat VAR21 $38. ; > informat VAR22 $7. ; > informat VAR23 $16. ; > informat VAR24 $3. ; > informat VAR25 $4. ; > format var1 $150. ; > format VAR2 $20. ; > format VAR3 $18. ; > format VAR4 $9. ; > format VAR5 $16. ; > format VAR6 $1. ; > format VAR7 $3. ; > format VAR8 $4. ; > format VAR9 $1. ; > format VAR10 $24. ; > format VAR11 $1. ; > format VAR12 $7. ; > format VAR13 $16. ; > format VAR14 $3. ; > format VAR15 $4. ; > format VAR16 $33. ; > format VAR17 $7. ; > format VAR18 $16. ; > format VAR19 $3. ; > format VAR20 $4. ; > format VAR21 $38. ; > format VAR22 $7. ; > format VAR23 $16. ; > format VAR24 $3. ; > format VAR25 $4. ; > input > VAR1 $ > VAR2 $ > VAR3 $ > VAR4 $ > VAR5 $ > VAR6 $ > VAR7 $ > VAR8 $ > VAR9 $ > VAR10 $ > VAR11 $ > VAR12 $ > VAR13 $ > VAR14 $ > VAR15 $ > VAR16 $ > VAR17 $ > VAR18 $ > VAR19 $ > VAR20 $ > VAR21 $ > VAR22 $ > VAR23 $ > VAR24 $ > VAR25 $ > ; > if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR > detection macro variable */ > > run; > > data perm.rec_seas_&datasetname; > set work.temp; > > length eeog $2.; > eeog=scan(var1,1,'.'); > if eeog in ('01','02','03','04','05','06','07','08','09','10', > '11','12','13','14','To','Oc'); > > if var1='Occupational Groups' then var1=&fieldname; > > proc print data=perm.rec_seas_&datasetname; > var var1 var2;run; > > %mend csvtodat; > > > *** an array loop to go through all the field units***; > > data _null_; > array east (3) $ ('AAA01','AAA02','AAA03'); > > do i=1 to 3; > fus=east(i); > *put fus; > call symput('unit',fus); > > %csvtodat(unit,unit,unit); > end; > run; > > (PS. If you're wondering what's going on in that code, until such a > time as I figure out an alternative way to import html tables into > SAS, what we're doing is saving the file as CSV using excel, and > importing that csv into SAS, dropping the header and footer. The > identity of the table is based on the filename. It's a pain, and so is > the other program we have to use to process the data.) >


Back to: Top of message | Previous page | Main SAS-L page