Hi ,
I am new to ODS/graph and I want to create a bar chart on the individual values in a numeric variable. The values are rounded to the nearest 2nd decimal point and they pretty close in value to each other. There are 100 such values. I tried using the discrete option on proc gchart after vbar statement but I get a chart that is very crowded. I want to know how to increase the chart area. Also, I am not sure if it worked since it was so crowded. Please advice . Unfortunately, I was not able to copy paste the data, graph or attach a file.
I haven't seen your code, but consider using PROC SGPLOT instead (SAS 9.2 or greater). You will be able to use FITPOLICY=THIN to drop the crowded values. For example,
proc sgplot data=sashelp.heart;
xaxis fitpolicy=thin;
vbar AgeAtStart / response=weight stat=mean;
run;
Hope this helps!
Use a browser other than IE to copy/paste code. You can attach a file with graphics as well.
I haven't seen your code, but consider using PROC SGPLOT instead (SAS 9.2 or greater). You will be able to use FITPOLICY=THIN to drop the crowded values. For example,
proc sgplot data=sashelp.heart;
xaxis fitpolicy=thin;
vbar AgeAtStart / response=weight stat=mean;
run;
Hope this helps!
Thanks DanH. Reeza I took your advice. I am going to try your sugesstion DanH and the code I used was
proc gchart data=final;
vbar var1/discrete;
run;
Here is the data that I am working on and that's the graph I need. Would proc gchart work for this ? What can I do to manipulate the chart area /
var1 |
1.65 |
4.83 |
6.14 |
6.56 |
8.35 |
9.22 |
9.57 |
10.23 |
10.67 |
11.98 |
45.23 |
67.54 |
34.53 |
Hi Dan, I tried your code , but I am not happy with the results. Do you have any suggestions for gchart ?
What version of SAS are you on?
You also need to be more explicit than "I'm not happy with that chart".
data have;
input var1;
cards;
1.65
4.83
6.14
6.56
8.35
9.22
9.57
10.23
10.67
11.98
45.23
67.54
34.53
;
run;
data have;
set have;
category=_n_;
run;
proc sgplot data=have;
vbarparm category=category response=var1/barwidth=0.5;
run;quit;
Actually DanH and Reeza I take back my words. I missed adding an 'ID' to the dataset and tried sgplot again and it worked (the same way as Reeza created the category variable). I realized something was wrong soon after. But, that is not what is needed.
I need the individual value of var1 on the x-axis and its corresponding frequency on the y-axis. I tried that with gchart and it worked ,but had done it with values rounded to the nearest whole number. I need to repeat it with the values rounded to the 2nd decimal point.
Thanks to both of you for your input.
Have you tried applying a format like f5.2 to the Y axis variable?
@ballardw..No I haven't, but will now . Thanks !
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.