You do not always need a period (a dot) to resolve a macro, except the macro value only constitutes part of your string then you need a dot to separate the two parts. For examples (I typed code here and run the code in windowing environment 9.4 base, btw😀 and this does not make any difference just somehow want to mention it btw😀)
%let var=employee;
%put Employees resolves to &var.s as it is.;
%let lib=weight;
%let table=itt;
%put The dataset weight.itt resolves to &lib..&table as it is.;
Please discard my first %let macro in my last thread (the way I create that %let macro was odd and funny, I don't know what's wrong with my mind then 😀). Here is the right one (and you do not need to use one more ampersand to resolve the macro):
data weight;
input subjid weight itt $ pp $;
datalines;
101 50 y y
102 55 y y
103 58 y y
104 60 n y
105 66 n y
106 67 y n
107 68 y n
108 70 y n
109 71 y y
110 72 y y
111 80 n y
112 49 y n
112 48 y n
114 49 y y
115 45 y y
;
run;
proc print data=weight;
run;
/**create %let macro to print
dataset for different population**/
%let pop=itt;
data weight_&pop;
set weight;
if &pop="y";
run;
proc print data=weight_&pop;
run;
%let pop=pp;
data weight_&pop;
set weight;
if &pop="y";
run;
proc print data=weight_&pop;
run;
And also I forgot to write the proc print step in the second macro in my previous thread, here is the correction:
%macro popset(table,var);
%local table var;
data &table._&var;
set &table;
if &var='y';
run;
proc print data=&table._&var;
run;
%mend popset;
%popset(weight,itt);
%popset(weight,pp);
'ITT' stands for 'Intend To Treat' population. I forget what 'PP' stands for. I read the terms in some materials about clinical trial dataset before. 'ITT' should be the column name if I remember it right, and has value of "Y" (which flags this subject belongs to ITT population) and "N" (which flags this subject does not belong to ITT population). Mean statistics is calculated base on different populations, sometimes you need to report statistics for all samples(or subjects, participants), other times you need statistics for the ITT population only.
PP stands for Per-Protocol analysis population. 🙂
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.