hi all,
I wanted to ask how can edit this code to run without error
%macro count_pt ;
proc sql;
select count(distinct patient_id), count (*)
into:patients trimmed into:obs
from &syslast. ;
quit ;
%put There are &patients. and &obs. from &syslast. ;
%mend count_pt ;
%count_pt;
You should be able to reorganize one line:
into : patients trimmed, : obs
@manya92 wrote:
hi all,
I wanted to ask how can edit this code to run without error
%macro count_pt ; proc sql; select count(distinct patient_id), count (*) into:patients trimmed into:obs from &syslast. ; quit ; %put There are &patients. and &obs. from &syslast. ; %mend count_pt ; %count_pt;
I would be very hesitant to say a macro that relies on referencing the last created data set for input and mentioning specific variables could ever be made to run "without errors" without providing code to check that the variables used exist in the data set. At which point you may need to have some code outside of this macro to modify following code behavior when the &syslast data set does not contain the patient_id variable.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.