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

I'm outputting percentages from a proc freq to a new dataset and then using proc sgplot to plot the column percentages over time. SAS documentation seems to suggest I should use the PCTNDEC= option, but I can't figure out where to put it. 

Is this the best option to use and what line should I put it on? 

proc sgplot data=freqout ;
   where ever_told_mi=1;

   series x=year y=pct_row 
   
   / lineattrs=(thickness=2px) markers DATALABEL=pct_row group=cann_use_status;

   xaxis 
   label = "Time in 2-year intervals"
   values=(2009-2010 to 2017-2018);
  
   yaxis 
   label = "Percentage Reporting Prior MI"
   values=(0 to 100 by 10);
 	
   format 
   ever_told_mi yes_nofmt.
   cann_use_status cann_use_statusfmt.;
 
run;

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If the YAXIS definition is getting the values you want and just want to display values such as 10.0 then all you should need is to assign an appropriate format to the Y variable labels with the VALUESFORMAT= option on the Yaxis statement.

It would help if you could describe exactly what sort of values you want.

 

The PCTNDEC procedure option only applies to plots that calculate their own percentages such as VBAR or HBAR and would not apply to Series

 

Example that forces the Yaxis tickmarks to display 3 decimals (though they will typically be 000 because of the default rules SAS uses to create tick mark values)

Proc sgplot data=sashelp.class;
   scatter x=height y=weight;
   yaxis valuesformat=f8.3;
run;

Or if you have specific decimals in mind place them in the VALUES list:

Proc sgplot data=sashelp.class;
   scatter x=height y=weight;
   yaxis values=(60.5 93.7 110.9);
run;

 

View solution in original post

2 REPLIES 2
ballardw
Super User

If the YAXIS definition is getting the values you want and just want to display values such as 10.0 then all you should need is to assign an appropriate format to the Y variable labels with the VALUESFORMAT= option on the Yaxis statement.

It would help if you could describe exactly what sort of values you want.

 

The PCTNDEC procedure option only applies to plots that calculate their own percentages such as VBAR or HBAR and would not apply to Series

 

Example that forces the Yaxis tickmarks to display 3 decimals (though they will typically be 000 because of the default rules SAS uses to create tick mark values)

Proc sgplot data=sashelp.class;
   scatter x=height y=weight;
   yaxis valuesformat=f8.3;
run;

Or if you have specific decimals in mind place them in the VALUES list:

Proc sgplot data=sashelp.class;
   scatter x=height y=weight;
   yaxis values=(60.5 93.7 110.9);
run;

 

_maldini_
Barite | Level 11

Sorry for not being more clear...The VALUESFORMAT= option formats the decimal places on the axis, which I also wanted. I was wanting to format the values of the Y variable and your response jogged my memory. I just need to format the Y variable. Duh.

Thanks! 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1656 views
  • 2 likes
  • 2 in conversation