Help using Base SAS procedures

Labels not appearing in proc freq

Reply
New Contributor
Posts: 3

Labels not appearing in proc freq

Hi,

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:

data PTSD;

     set WWR.Adult_Baseline;

     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)";

  run;

proc format;

        value servicemembercleanft 0="Civilian Parent" 1="Service Member";

        value yes_noft 0='No' 1='Yes';
run;

  proc freq data=PTSD;

        tables servicememberclean*PCLpre30 servicememberclean*PCLpre50/list missing;

        format servicememberclean servicemembercleanft. PCLpre30 PCLpre50 yes_noft.;

  run;

PROC Star
Posts: 7,492

Re: Labels not appearing in proc freq

Posted in reply to msinclair

You can get what you want by modifying the template that is used.  Take a look at:

http://support.sas.com/kb/23/350.html

New Contributor
Posts: 3

Re: Labels not appearing in proc freq

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?

PROC Star
Posts: 7,492

Re: Labels not appearing in proc freq

Posted in reply to msinclair

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.

SAS Super FREQ
Posts: 8,868

Re: Labels not appearing in proc freq

Hi:

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.

cynthia

PROC Star
Posts: 7,492

Re: Labels not appearing in proc freq

Posted in reply to Cynthia_sas

Cynthia,

Thanks for pointing that out, but I think there is a simpler alternative.  How about?:

options validvarname=any;

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

             /list missing;

      format servicememberclean servicemembercleanft.

             "High Distress (Cut-off of 30)"n

             "High Distress (Cut-off of 50)"n yes_noft.;

run;

SAS Super FREQ
Posts: 8,868

Re: Labels not appearing in proc freq

Art:

  Very clever! As long as you're willing to use that type of naming convention, it is way easier than changing the table template!

cynthia

New Contributor
Posts: 3

Re: Labels not appearing in proc freq

Posted in reply to Cynthia_sas

Thank you both so much. I just tried it and it worked!!

Ask a Question
Discussion stats
  • 7 replies
  • 6163 views
  • 0 likes
  • 3 in conversation