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

Please correct me if I miss something because just right now the example is a typical example showing how graph can make the user mad.

 

In the example two formats are used; one is assigned to the variable using the format statement ; the other one is set using the option tickvalueformat.

 

My original thought was that tickvalueformat would have priority over the variable format to set the tickvalues and that the variable format would be used to set the order of the bars.

 

However, in this example, we can see that the tick values are coming from the format assigned to the variable, but the format width is coming from the format given in the tickvalueformat option. As the default format label with of the sex format is 6, tick values are truncated.

 

proc format;
    value $sex 'M'='Male'
               'F'='Female';
    value $sexnum 'M'='1-Male'
                  'F'='2-Female';
              
run;
    
proc sgplot data=sashelp.class noborder;
    vbarbasic sex; 
    
    xaxis discreteorder=formatted tickvalueformat=$sex.;
    
    format sex $sexnum.;
run;
    
proc sgplot data=sashelp.class noborder;
    vbarbasic sex; 
    
    xaxis discreteorder=formatted tickvalueformat=$sex20.;
    
    format sex $sexnum.;
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Have a look at the following code sample. Two format are created, the first one is used for the ordering of the bars, the second one is used to label the tick marks. Note that the second format uses the formatted values as the input value. No truncation takes place.

 

proc format;
  value $sex 
    'M'='1Male'
    'F'='2Female'
  ;
  value $sextick 
    '1Male'='Männlich'
    '2Female'='Weiblich'
  ;
run;

title "just format statement";
proc sgplot data=sashelp.class noborder;
  vbarbasic sex;
  xaxis discreteorder=formatted 
/*    valuesformat=$sextick.*/
  ;
  format sex $sex.;
run;
title;

title "with valuesformat";
proc sgplot data=sashelp.class noborder;
  vbarbasic sex;
  xaxis discreteorder=formatted 
    valuesformat=$sextick.
  ;
  format sex $sex.;
run;
title;

View solution in original post

4 REPLIES 4
BrunoMueller
SAS Super FREQ

Have a look at the following code sample. Two format are created, the first one is used for the ordering of the bars, the second one is used to label the tick marks. Note that the second format uses the formatted values as the input value. No truncation takes place.

 

proc format;
  value $sex 
    'M'='1Male'
    'F'='2Female'
  ;
  value $sextick 
    '1Male'='Männlich'
    '2Female'='Weiblich'
  ;
run;

title "just format statement";
proc sgplot data=sashelp.class noborder;
  vbarbasic sex;
  xaxis discreteorder=formatted 
/*    valuesformat=$sextick.*/
  ;
  format sex $sex.;
run;
title;

title "with valuesformat";
proc sgplot data=sashelp.class noborder;
  vbarbasic sex;
  xaxis discreteorder=formatted 
    valuesformat=$sextick.
  ;
  format sex $sex.;
run;
title;
yabwon
Onyx | Level 15

Fun fact, the SGPLOT/XAXIS documentation does not mention about the tickvalueformat= option at all. The tickvalueformat= is only documented in GTL reference.

 

Bart

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



xxformat_com
Barite | Level 11
Thanks. So the format in valuesformat= applies to the formatted values and not to the unformatted values. My mind would never have imagine this construct. It's clear now.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4 replies
  • 406 views
  • 2 likes
  • 3 in conversation