BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jaelee22
Fluorite | Level 6

Hello everyone, 

 

I have a question formatting my syntax. I have a large data set but I am trying to make a box plot of the frequency of the a specific variable. 

I have variable subject ID, and measurement A. 

measurement A ranges from 20 mm to 30 mm

I have to see how many people are in measurment A from 20-20.99, 21-21.99, to 29-29.99

Please help. 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

I made up some random data, and then I used PROC SGPLOT (not PROC GPLOT, which is an older procedure) to generate the plot.

 

data random;
	do i=1 to 275;
    y=rand('uniform')*10+20;
	output;
	end;
run;

proc sgplot data=random;
	histogram y/binstart=20 binwidth=1 scale=count showbins;
run;
--
Paige Miller

View solution in original post

8 REPLIES 8
PaigeMiller
Diamond | Level 26

Typically, you do not use box plots to show "the frequency of the a specific variable." Box plots are designed to show the continuous distribution of a variable, I'm sure you can find examples in the SAS documentation or on the internet.

 

I have to see how many people are in measurement A from 20-20.99, 21-21.99, to 29-29.99

This sounds like a histogram, or perhaps PROC FREQ. Is that what you want?

--
Paige Miller
jaelee22
Fluorite | Level 6

Thank you Paige, 

Yes you were right, it was a box plot but how can i format the syntax so the labels be from 20-30 increments of 1. 

or  can I write my own labels?

PaigeMiller
Diamond | Level 26

I'm sorry, I still don't understand what plot you want. 

 

Yes you were right, it was a box plot 

 

This statement of yours is contradictory, I say you don't want a box plot and you say you do want a box plot, and I'm right?

 

Can you find a similar plot on the Internet and show us a screen capture?


Can you show us a small example of data set and explain how this turns into a box plot?

--
Paige Miller
jaelee22
Fluorite | Level 6

Sorry for the confusion. I met a bar graph. 

So I am using proc gchart to create a bar graph. 

In my data set I have n= 4135 subjects, with measurement x. Some subjects don't have a x measurement.

measurement x ranges from 20-30mm. 

What I want to create is a bar graph of the number of people based on x. 

PaigeMiller
Diamond | Level 26

I made up some random data, and then I used PROC SGPLOT (not PROC GPLOT, which is an older procedure) to generate the plot.

 

data random;
	do i=1 to 275;
    y=rand('uniform')*10+20;
	output;
	end;
run;

proc sgplot data=random;
	histogram y/binstart=20 binwidth=1 scale=count showbins;
run;
--
Paige Miller
jaelee22
Fluorite | Level 6

can I add something to show the actual number count on each bar? 

 

Thank you for all your help. 

PaigeMiller
Diamond | Level 26

histogram y/binstart=20 binwidth=1 scale=count showbins datalabel=count;

 

--
Paige Miller
jaelee22
Fluorite | Level 6

thank you once again

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1886 views
  • 0 likes
  • 2 in conversation