BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Miracle
Barite | Level 11

Dear All,

May I please ask why am I getting this "NOTE: stat=PCT is invalid. The default will be used." from my proc sgrender? What is the default?

Below is the partial code from proc template. I am using SAS 9.4.

Thank you in advance.

993        proc template;
994           define statgraph unifonts;
995           begingraph;
996           *entrytitle 'Reason';
997           entryfootnote ' ' / textattrs=(size=40 );
998              layout overlay / xaxisopts=(display=( tickvalues)  type=DISCRETE linearopts=( /*tickvaluelist=( 12 13
998      ! 14 15 16 17 18 19 )*/  tickdisplaylist=( 'Two or fewer hours' 'Full day'
999        'Half a day' '2 days'  'More than 2, up to 4 days' 'More than 4, up to 8 days' 'More than 8, up to 15 days'
999      ! 'It never stops' )   viewmin=12 viewmax=19 )
1000          DISCRETEOPTS=(TICKVALUEROTATION=DIAGONAL TICKVALUEFITPOLICY=ROTATE SORTORDER=DATA
1000     ! TICKVALUESPLITCHARDROP=TRUE))
1001       yaxisopts=(label="Percentage of subjects" offsetmin=0 griddisplay=on linearopts=(tickvaluesequence=(start=0
1001     ! end=100 increment=10) tickvaluepriority=true));
1002       
1003                barchart x=QUERES1C y=PCT_  / group=AGECAT1F groupdisplay=cluster name='agecat' Stat=PCT
1004                          barwidth=1  barlabel=true barlabelattrs=(size=9pt )   barlabelformat=PCTBARLF. display=all
.
.
.
1031 proc sgrender data=final template=unifonts ; run;

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Miracle,

 

The BARCHART statement documentation says: "For bar charts with a RESPONSE= column, the default is SUM."

This applies to your code because Y= is an alias of RESPONSE=.

 

So, if your response variable PCT_ contains percentage values such as 12.34 (meaning 12.34%), the default statistic SUM is likely what you want anyway (and you can just omit the STAT= option), especially if your input dataset final contains at most one observation per combination of QUERES1C and AGECAT1F. In case of more than one observation per combination the individual values would be summed up (like 12.34%+11.5%=23.84%).

 

The specification STAT=PCT in the absence of a RESPONSE= column (i.e., without Y=PCT_ or without a variable PCT_ in the input dataset), however, would instruct SAS to compute the percentages. That is, SAS would count the observations in each QUERES1C-AGECAT1F category (and the overall total) and use the relative frequencies times 100 as the heights of the bars.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hello @Miracle,

 

The BARCHART statement documentation says: "For bar charts with a RESPONSE= column, the default is SUM."

This applies to your code because Y= is an alias of RESPONSE=.

 

So, if your response variable PCT_ contains percentage values such as 12.34 (meaning 12.34%), the default statistic SUM is likely what you want anyway (and you can just omit the STAT= option), especially if your input dataset final contains at most one observation per combination of QUERES1C and AGECAT1F. In case of more than one observation per combination the individual values would be summed up (like 12.34%+11.5%=23.84%).

 

The specification STAT=PCT in the absence of a RESPONSE= column (i.e., without Y=PCT_ or without a variable PCT_ in the input dataset), however, would instruct SAS to compute the percentages. That is, SAS would count the observations in each QUERES1C-AGECAT1F category (and the overall total) and use the relative frequencies times 100 as the heights of the bars.

Miracle
Barite | Level 11

Hi @FreelanceReinh.

Thanks for the quick explanation.

It really helps. I understand now.

sas-innovate-2024.png

📢

ANNOUNCEMENT

The early bird rate has been extended! Register by March 18 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

How to Concatenate Values

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.

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
  • 2 replies
  • 473 views
  • 2 likes
  • 2 in conversation