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

Hello 

data have;
infile cards;
input Obs Unique_ID time age1 ubn phs;
cards;
34 115 0 1 1 29.0335
35 115 1 1 1 29.0335
36 115 3 1 0 32.9291
37 116 0 3 1 57.3839
38 116 1 3 1 58.8820
39 116 3 3 1 59.1443
40 117 0 2 4 37.7653
41 117 1 2 4 23.7625
42 117 3 2 3 27.7563
43 118 0 2 2 32.2473
44 118 1 2 2 48.3631
45 118 3 2 3 44.0582
46 119 0 3 1 35.5357
47 119 1 3 2 37.6650
48 119 3 3 1 53.2719
49 120 0 2 1 55.4447
50 120 1 2 0 52.6279
51 121 0 2 4 56.7920
;
proc print;
proc format;
value timef 0='2006' 1='2007' 3='2009';
value ubnf 4='1.4unmet' 3='2.3unmet' 2='3.2unmet' 1='4.1unmet' 0='5.0unmet';
value age1f 3='1.old' 2='2.mid-age' 1='3.young'; run;
proc freq;
tables time ubn age1; run;

proc sgpanel data=have;
panelby time / onepanel layout=columnlattice colheaderpos=bottom noborder novarname;
vbar ubn / group=age1 groupdisplay=cluster response=age1 grouporder=data ;
rowaxis display=(nolabel);
colaxis display=(nolabel);
format time timef.;
format ubn ubnf.;
format age1 age1f.;
run;

proc sgpanel data=have;
panelby time / onepanel layout=columnlattice colheaderpos=bottom noborder novarname;
vbar age1 / group=ubn groupdisplay=cluster response=ubn grouporder=data ;
rowaxis display=(nolabel);
colaxis display=(nolabel);
format time timef.;
format ubn ubnf.;
format age1 age1f.;
run;

I appreciate your help. I want to create a chart with sgpanel from

https://communities.sas.com/t5/Graphics-Programming/Bar-chart-with-a-group-and-subgroup/td-p/669034

 

How can I improve my charts: a) bigger, b) add labels on Y and X, and c) with 'Histogram' NOT 'Vbar'

Thank you very much !!!

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

For #!, do the following:

  • Add NOVALUES to the DISPLAY option on the COLOAXIS statement: display=(nolabel novalues)
  • Set GROUPORDER=DESCENDING on the VBAR statement
  • To fix the Y axis values, you will need to copy "ubn" to a separate column and unset the user-defined format

For #2, the the graph probably does not display because the values in the VALUES list do not match up against the formatted values from your data.

View solution in original post

7 REPLIES 7
ballardw
Super User

If by "bigger" you mean the whole graphics area that is the ODS GRAPHICS statement Height and Width options.

If something else is meant then you need to tell us what needs to be larger.

 

The LABEL='text' option on the Rowaxis and Colaxis statements sets a label. If that isn't sufficient then you need to describe in considerably more detail what you want. I did not notice that every one of your shown graphs specifically uses the NOLABEL option so there wouldn't be one.

 

Histogram where?

 


@PhanS wrote:

Hello 

data have;
infile cards;
input Obs Unique_ID time age1 ubn phs;
cards;
34 115 0 1 1 29.0335
35 115 1 1 1 29.0335
36 115 3 1 0 32.9291
37 116 0 3 1 57.3839
38 116 1 3 1 58.8820
39 116 3 3 1 59.1443
40 117 0 2 4 37.7653
41 117 1 2 4 23.7625
42 117 3 2 3 27.7563
43 118 0 2 2 32.2473
44 118 1 2 2 48.3631
45 118 3 2 3 44.0582
46 119 0 3 1 35.5357
47 119 1 3 2 37.6650
48 119 3 3 1 53.2719
49 120 0 2 1 55.4447
50 120 1 2 0 52.6279
51 121 0 2 4 56.7920
;
proc print;
proc format;
value timef 0='2006' 1='2007' 3='2009';
value ubnf 4='1.4unmet' 3='2.3unmet' 2='3.2unmet' 1='4.1unmet' 0='5.0unmet';
value age1f 3='1.old' 2='2.mid-age' 1='3.young'; run;
proc freq;
tables time ubn age1; run;

proc sgpanel data=have;
panelby time / onepanel layout=columnlattice colheaderpos=bottom noborder novarname;
vbar ubn / group=age1 groupdisplay=cluster response=age1 grouporder=data ;
rowaxis display=(nolabel);
colaxis display=(nolabel);
format time timef.;
format ubn ubnf.;
format age1 age1f.;
run;

proc sgpanel data=have;
panelby time / onepanel layout=columnlattice colheaderpos=bottom noborder novarname;
vbar age1 / group=ubn groupdisplay=cluster response=ubn grouporder=data ;
rowaxis display=(nolabel);
colaxis display=(nolabel);
format time timef.;
format ubn ubnf.;
format age1 age1f.;
run;

I appreciate your help. I want to create a chart with sgpanel from

https://communities.sas.com/t5/Graphics-Programming/Bar-chart-with-a-group-and-subgroup/td-p/669034

 

How can I improve my charts: a) bigger, b) add labels on Y and X, and c) with 'Histogram' NOT 'Vbar'

Thank you very much !!!

 


 

 

PhanS
Obsidian | Level 7

Good morning Ballardw!

Thank you! ODS Graphics on Height and With Option improve the size of mt graphs.    

Please see three scenarios (I use SAS onDemand) in attachment - what are the issues with my codes?

ballardw
Super User

@PhanS wrote:

Good morning Ballardw!

Thank you! ODS Graphics on Height and With Option improve the size of mt graphs.    

Please see three scenarios (I use SAS onDemand) in attachment - what are the issues with my codes?


You will need to describe what is wrong with any of those graphs to determine what an "issue" might be.

If it relates to axis labels as previous the option you are using NOLABEL means that there is no label. You have to use Label='some text' on the row or column axis to have a label appear other than the default.

PhanS
Obsidian | Level 7

Follow up - please see my sepcific issues in attachment. 

ballardw
Super User

Please at least post the code in the message windows.

 

You have custom formats. Without actual data set AND the definitions of those formats there is not way to tell what is needed to control order.  If your Grouporder variable doesn't have a natural 'sort' order that matches your display desire so that either Ascending or Descending makes sense, or the values do not appear in order in the data set (sorted before the Proc Sgpanel/Sgplot) then you may have to change the values or create a new variable that will sort in the order you want. Note that with Panel variables the interaction of presorting may not match what you want either for all groups.

 

Or why a graph wasn't created. What does your log show? A guess is that the values you used in the axis do not actually exist in the data. Which is why the format definitions are needed. The VALUES are the actual values of the variable, not the formatted values.

DanH_sas
SAS Super FREQ

For #!, do the following:

  • Add NOVALUES to the DISPLAY option on the COLOAXIS statement: display=(nolabel novalues)
  • Set GROUPORDER=DESCENDING on the VBAR statement
  • To fix the Y axis values, you will need to copy "ubn" to a separate column and unset the user-defined format

For #2, the the graph probably does not display because the values in the VALUES list do not match up against the formatted values from your data.

PhanS
Obsidian | Level 7

RESOLVED! Thank you very much Dan!

It works as I should 🙂

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
  • 7 replies
  • 1177 views
  • 0 likes
  • 3 in conversation