Hi all, I'm using the below code to generate an automated SAS output as a dataset from proc GLM. I have 14 outcome variables on which I need to run the same model. I was hoping. I am able to get the output like I want for one variable. However with my current code when I run it for all 14 variables, the outputs get stacked on top of each other and there is no way to tell which set of estimates correspond to which SAS variable. The transpose procedure marks estimates and p-values from 1-14 and I currently cross check with the SAs output in the results viewer to verify the correct outcome and solution. I was hoping if I would be able to add the name of the outcome variable in my output dataset. It'd be a lot more easier for me. I have highlighted the specific part (text in blue) where I want to insert it. Is there a way for SAS to automatically set the value of the variable outcome as the name of the outcome variable that it's currently running?? %macro MODEL1acpo (yvar1a, out1a); *the below is to output the table that we refer to as a dataset; ods output ParameterEstimates = data1(keep=parameter estimate Probt); /*ods choose the wanted output tables IN THIS CASE EFFECT WHICH TELLS THE VARIABLE NAME, ESTIMATE AND P-VALUE */ *this is the actual model, Change outcome variable is the only macro variable here; proc glm data= cleft.cleft_cleaned; class childsex (ref='1') race_col (ref='1') furlow (ref='0') second_pal_surg (ref='0'); model &yvar1a = childage childsex race_col sf_SES_score complete_incom age_pripalate dem_4cp_surgeries furlow second_pal_surg/solution clparm; where cleft_dx_new= 1 and adopt= 0; title 'Hyp 1A: Parent Model CPO &yvar1a'; title; run; *This is clening up the output dataset to round off the estimates and probablity tables; data &out1a; set data1; where parameter ne 'Intercept' and estimate ne 0; /* output estimate, 95%CI and p-value*/ estimate_= round (estimate, 0.01); if (0.04 < Probt < 0.06) then probt_ = round (probt, 0.001); else probt_= round (probt, 0.01); drop estimate probt; rename estimate_= estimate probt_= probt; outcome= &yvar1a; run; %mend model1acpo; %let outcomes= cbcltotpraw cbclepraw cbclipraw cbcltcraw cbclschraw cbclaraw cbclsraw cbcladhraw cbclafpraw cbclanpraw cbclsompraw cbclodpraw cbclcpraw cbclptsraw; %model1acpo (&outcomes, Output_1a_CPO); proc sort data= Output_1a_CPO; by parameter; run; proc transpose data=Output_1a_CPO out=estimate_wide name=variable prefix=Estimate; by parameter; var estimate; /* transpose the table from long to wide format*/ run; proc transpose data=Output_1a_CPO out=p_wide name=variable prefix=P_value; by parameter; var probt; /* transpose the table from long to wide format*/ run; Proc sort data= estimate_wide; by parameter; run; Proc sort data= p_wide; by parameter; run; data model1_output; merge estimate_wide p_wide; by parameter; run; Thanks for helping!!
... View more