BookmarkSubscribeRSS Feed
msinclair
Calcite | Level 5

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;

7 REPLIES 7
art297
Opal | Level 21

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

msinclair
Calcite | Level 5

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?

art297
Opal | Level 21

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.

Cynthia_sas
SAS Super 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

art297
Opal | Level 21

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;

Cynthia_sas
SAS Super 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

msinclair
Calcite | Level 5

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 14374 views
  • 1 like
  • 3 in conversation