11-09-2012 01:42 PM
I am using SAS 9.3 and for some reason my labels are not appearing on my variables when I do a general Proc Freq. They appear fine with a Proc Print or Proq Freq/Chisq. I have even looked at the Dataset contents to make sure the label appears and it does.
Here is my code:
if PCLTotalScore_PRE ge 30 then PCLpre30=1;
else if PCLTotalScore_PRE lt 30 then PCLpre30=0;
if PCLTotalScore_PRE ge 50 then PCLpre50=1;
else if PCLTotalScore_PRE lt 50 then PCLpre50=0;
label PCLpre30="High Distress (Cut-off of 30)"
PCLpre50="High Distress (Cut-off of 50)";
value servicemembercleanft 0="Civilian Parent" 1="Service Member";
value yes_noft 0='No' 1='Yes';
proc freq data=PTSD;
tables servicememberclean*PCLpre30 servicememberclean*PCLpre50/list missing;
format servicememberclean servicemembercleanft. PCLpre30 PCLpre50 yes_noft.;
11-09-2012 06:00 PM
Thank you for this.
However, I have never used Proc Template so I do not understand which parts need to be altered to get my variable labels to show up. Any suggestions?
11-09-2012 07:15 PM
If you run the code in that example, you will see that their use of proc template does (I think) precisely what you are trying to accomplish.
11-09-2012 09:39 PM
The only issue is that the example uses the OneWayFreqs output object, but the OP created output using the LIST option, which changes the output object that is used. The output object used for LIST output is OneWayList. So while the general method would be the same, the template that needs to change would be different.
It might be easier to use PROC TABULATE, since it uses labels by default. Or, possibly easier than learning TABULATE, is to make an output dataset with PROC FREQ and then using PROC PRINT with a LABEL option to print the dataset from FREQ.
11-09-2012 11:47 PM
Thanks for pointing that out, but I think there is a simpler alternative. How about?:
proc freq data=PTSD (rename=(PCLpre30="High Distress (Cut-off of 30)"n
PCLpre50="High Distress (Cut-off of 50)"n));
tables servicememberclean*"High Distress (Cut-off of 30)"n
servicememberclean*"High Distress (Cut-off of 50)"n
format servicememberclean servicemembercleanft.
"High Distress (Cut-off of 30)"n
"High Distress (Cut-off of 50)"n yes_noft.;
11-10-2012 09:16 AM
Very clever! As long as you're willing to use that type of naming convention, it is way easier than changing the table template!