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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

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!

View solution in original post

9 REPLIES 9
Reeza
Super User

Use a browser other than IE to copy/paste code. You can attach a file with graphics as well.

DanH_sas
SAS Super FREQ

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!

dr2014
Quartz | Level 8

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

dr2014
Quartz | Level 8

Hi Dan, I tried your code , but I am not happy with the results. Do you have any suggestions for gchart ?

Reeza
Super User

What version of SAS are you on?

Reeza
Super User

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;

dr2014
Quartz | Level 8

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.

ballardw
Super User

Have you tried applying a format like f5.2 to the Y axis variable?

dr2014
Quartz | Level 8

@ballardw..No I haven't, but will now . Thanks !

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1466 views
  • 7 likes
  • 4 in conversation