I'm Using Base SAS 9.4 TM5 on a Windows 7 Desktop. I'm trying to run a data step that utilizes a Call Execute Statement that runs a macro given the parameters from the observation in the data step and takes the Macro Variables from the Call Execute Statement and saves it as a data set variables to the current data set where Rx_Fill_Date is. See an excerpt from the code data PMP_all_temp;
--- additional code up here ---
CALL EXECUTE('%MDSLkup(ID='||TRIM(LEFT(Subj_ID_file))||',Date='||Rx_Fill_Date||');');
MAT_DoseStatus = SYMGET('MAT_DoseStatus');
MAT_Dose = SYMGET('MAT_Dose');
MAT_THB = SYMGET('MAT_THB');
MAT_Phase = SYMGET('MAT_Phase');
MAT_Epicount = SYMGET('MAT_Epicount');
MAT_EpiStatus = SYMGET('MAT_EpiStatus');
MAT_Admit1 = SYMGET('MAT_Admit1');
MAT_Discharge1 = SYMGET('MAT_Discharge1');
MAT_Admit2 = SYMGET('MAT_Admit2');
MAT_Discharge2 = SYMGET('MAT_Discharge2');
drop pos;
run The Macro in question is essentially a lookup macro where it looks up the Date and Subject_ID and returns the data that is stored for that date from a larger dataset of about 20,000 variables. %MACRO MSDLkup(ID=,Date=);
Lookup_ID = "&ID.";
Lookup_Date = &date.;
---- ARRAY Declaration Statements and other necessary code -----
nvalues_epi = N(of Episodes_DateAdmit1-Episodes_DateAdmit10);
if Subj_ID = Lookup_ID then do;
do i = 1 to 5000;
if Days[i] = Lookup_Date then do;
CALL SYMPUTX('MAT_DoseStatus',"Dosing Record Exist","G");
CALL SYMPUTX('MAT_Dose',Dose[i],"G");
CALL SYMPUTX('MAT_THB',THB[i],"G");
CALL SYMPUTX('MAT_Phase',P[i],"G");
CALL SYMPUTX('MAT_EpiCount',EpiCount[i],"G");
DoseOutput = 1;
end;
end;
if DoseOutput = . THEN DO;
CALL SYMPUTX('MAT_DoseStatus',"Dosing Record DOES NOT Exist for Date");
CALL SYMPUTX('MAT_Dose',"N/A","G");
CALL SYMPUTX('MAT_THB',"N/A","G");
CALL SYMPUTX('MAT_Phase',"N/A","G");
CALL SYMPUTX('MAT_EpiCount',"N/A","G");
DoseOutput = 1;
END; The problem that I'm having is that while the Call Execute is running correctly and correctly inputting the 7 Character Subject ID and the Date for each observation in the Macro as for each observation as evidented in my Log and a print out showing that a successful lookup was done for the first observation, the Macro Variables are not being overwritten for each iteration of the Call Execute statement, and thus the PROC Print of this dataset shows the same data for the first observation for all subsequent observations. How can I set up my Macro Variable to be overwritten so each iteration of call execute in each observation displays the unique data based on date and subject. Thank you!
... View more