Am Rusty at this, so please excuse the dumb question - but its driving me mad!
I have to read a large SAS file where each record contains (amongst other things) a char field NAM containing a variable name i.e 123abc99qz.
This field is part of a full path id for a SAS Library i.e. /DIR1/DIR2/DIR3/123abc99qz/DIR4/.
So, for each record on the input SAS file I need to:
(1)Extract the NAM variable & Create the full path id . I do it thus :
Attrib FULL_PATH Length Length=$40;
FULL_PATH = '/PATH1/PATH2/' || NAM || '/PATH4/';
ARRAY FP_ARRAY (1) $ FULL_PATH;
/* each FP_ARRAY variable now contains a valid SAS Library name */
(2) I now need to assign the value of each iteration of FULL_PATH to a variable that I can use to allocate a libname......
DO I = 1 to DIM(FP_ARRAY)
CALL SYMPUT ('LIB_ID',FP_ARRAY(i));
LIBNAME LIBLIB "&LIB_ID".
(2)Run Proc sort on a filename in this Library with "out=" & "where" parameters.
Easy - once the Library can be assigned
PROC SORT DATA=LIBLIB.filename;
(3)Run Proc Append to add the out= file specified previously to a permanent D/Set
(Again - Easy once the Library is assigned)
(4) Read the next record on the File untill all are processed.
I know that all processing must be done within FRED1 else the array will disappear...but it has me tearing my hair out.
Any advice on how to proceed (or indeed, an alternate processing suggestion) would be most appreciated.
If not interested in using MACRO language, consider using CALL EXECUTE to assign a SAS variable that contains each of your well-defined PROC steps. No array needed - just generate the SAS code and the steps will be executed serially after your main DATA step completes.
It's only that using MACRO language increased the PITA effect for debugging, because....let's see, where should I start...NO LINE NUMBERS REVEALED!! Sorry, increased cuban coffee consumption this Friday. Understandably, some have an aversion to embracing the SAS macro language unless absolutely required.
One trick that we used to use at a company that would not let SAS Macro programs in a production (scheduled job) was to do this:
build statements in code and then PUT them to flat file;
One advantage of this is that you can keep examining the "yadayada.sas" file to see that it's got the correct statements. We were allowed %include or SYSIN DD -- so it was a different approach but might work in this case.