Hi,
I am trying to create a stem-and-leaf plot of some data that I have but when I run the code, I get doubles for each stem value because the leaf value splits at 5. How can I stop this from occurring? Also, how can I sort the data in ascending order because currently the chart is printing in ascending order?
Here is the code I have so far:
The number of lines displayed in a line-printer plot, i.e. listing destination is controlled by the PLOTSIZE= option which the number of printed lines displayed including headers (text like Stem Leaf and information at the bottom.
proc univariate data=auto plots plotsize=10; VAR scf; run; quit;
Seems to get close with the given data for the Stem and Leaf though the order is still smallest to largest upwards.
If your data changes you may need to change the plot size. I think the default number of rows is based on the number of records and range of values.
Note that if you have more than 49 values you likely wont get a stem and leaf plot but a bar chart, of sorts.
It would help if you could attach an image of what you're getting and some indication of what you don't like about that.
@Fara_I wrote:
Hi,
I am trying to create a stem-and-leaf plot of some data that I have but when I run the code, I get doubles for each stem value because the leaf value splits at 5. How can I stop this from occurring? Also, how can I sort the data in ascending order because currently the chart is printing in ascending order?
Here is the code I have so far:
DATA auto;
INPUT scf;
CARDS;
31
35
42
43
43
43
44
44
45
47
48
49
50
50
53
53
54
59
61
62
70
73
76
;*PROC UNIVARIATE DATA=auto PLOTS;
ods listing;
ods graphics off;
proc univariate data=auto plots;
VAR scf;
run;
quit;I commented PROC UNIVARIATE DATA = auto PLOTS; out because I wasn't sure what the code does and it doesn't seem to change the output when I run it. I also need help printing the plot in ascending order because it is currently printing in descending order. I will appreciate any insight or input anyone can provide me. Thanks!
Can you post an example of your desired plot?
The number of lines displayed in a line-printer plot, i.e. listing destination is controlled by the PLOTSIZE= option which the number of printed lines displayed including headers (text like Stem Leaf and information at the bottom.
proc univariate data=auto plots plotsize=10; VAR scf; run; quit;
Seems to get close with the given data for the Stem and Leaf though the order is still smallest to largest upwards.
If your data changes you may need to change the plot size. I think the default number of rows is based on the number of records and range of values.
Note that if you have more than 49 values you likely wont get a stem and leaf plot but a bar chart, of sorts.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.