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):
58083 | CD | 58083 | 3.22 |
32952 | ML | 91035 | 5.04 |
148357 | LO | 239392 | 13.25 |
730125 | CL | 969517 | 53.68 |
480939 | ZX | 1450456 | 80.30 |
42497 | VC | 1492953 | 82.66 |
281371 | AD | 1774324 | 98.23 |
29846 | RT | 1804170 | 99.89 |
2036 | GN | 1806206 | 100.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?
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;
Thanks @PeterClemmensen working flawlessly.
@hiteshchauhan1, Anytime, glad to help 🙂
Hey @PeterClemmensen ,I think the output that i got is not a histogram and instead a bar chart. :
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 🙂
Thanks @PeterClemmensen
@hiteshchauhan1 Did this work for you? 🙂
If you want a more precise code answer, please post a part of your actual data
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.
Ok. If you need help with variable type conversion, post an example of your data 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.