BookmarkSubscribeRSS Feed
hiteshchauhan1
Obsidian | Level 7

Can i make a histogram in sas of the data that i obtained after running proc freq.

below is the example:

 

proc freq data=A.testrun;
TABLE uncd;
run;

 

The output i got after running the code is in this form (only first two columns are relevant to me):

 

  MNPBPNPSSNSSWS
58083CD580833.22
32952ML910355.04
148357LO23939213.25
730125CL96951753.68
480939ZX145045680.30
42497VC149295382.66
281371AD177432498.23
29846RT180417099.89
2036GN1806206100.00

 

Now i want to make a histogram which has these values like GN,RT,AD,VC on the X-Axis and The numbers in first column on Y- axis The first column is actually the frequency. Can this be achieved?

9 REPLIES 9
PeterClemmensen
Tourmaline | Level 20

Yes it is possible. However, you don't have to use the PROC FREQ output to do so. you can simply use PROC SGPLOT directly on your data and do something like this

 

proc sgplot data=A.testrun;
   vbar uncd;
run;

 

 

hiteshchauhan1
Obsidian | Level 7

Hey @PeterClemmensen ,I think the output that i got is not a histogram and instead a bar chart. :

PeterClemmensen
Tourmaline | Level 20

I think you're right. You can use the Histogram Statement directly instead like this

 

proc sgplot data=A.testrun;
   histogram uncd;
run;

Use the PROC SGPLOT Histogram documentation to improve the plot to your liking 🙂

PeterClemmensen
Tourmaline | Level 20

@hiteshchauhan1 Did this work for you? 🙂

 

If you want a more precise code answer, please post a part of your actual data 

hiteshchauhan1
Obsidian | Level 7

The code is working but to create a histogram the data should be numeric and the variable that i am using does not have numeric values. So, not working in my case but nonetheless the code is fine.

PeterClemmensen
Tourmaline | Level 20

Ok. If you need help with variable type conversion, post an example of your data 🙂

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 9 replies
  • 1119 views
  • 1 like
  • 2 in conversation