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 !!!
For #!, do the following:
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.
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 !!!
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?
@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.
Follow up - please see my sepcific issues in attachment.
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.
For #!, do the following:
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.
RESOLVED! Thank you very much Dan!
It works as I should 🙂
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!
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.