New SAS User

Completely new to SAS or trying something new with SAS? Post here for help getting started.
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Fara_I
Fluorite | Level 6

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!
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

3 REPLIES 3
Reeza
Super User

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!

 

PeterClemmensen
Tourmaline | Level 20

Can you post an example of your desired plot?

ballardw
Super User

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.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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