## PROC GCHART

Solved
Occasional Contributor
Posts: 9

# PROC GCHART

Hello everyone,

I have the following program:

``````data WORK.VELOCITY;
SET WORK.GETNOCS;
if noc_open_date=. or noc_close_date=. or first_noc = . then delete;
velocity = noc_close_date-open_date+1;
IF velocity < 25 then Velocity_GR = 1; ELSE
IF velocity < 50 then Velocity_GR = 2; ELSE
IF velocity < 75 then Velocity_GR = 3; ELSE
IF velocity < 100 then Velocity_GR = 4; ELSE
IF velocity < 125 then Velocity_GR = 5; ELSE
IF velocity < 150 then Velocity_GR = 6; ELSE
IF velocity < 175 then Velocity_GR = 7; ELSE
IF velocity < 200 then Velocity_GR = 8; ELSE
IF velocity < 225 then Velocity_GR = 9; ELSE
IF velocity < 250 then Velocity_GR = 10; ELSE
IF velocity < 275 then Velocity_GR = 11; ELSE
IF velocity < 300 then Velocity_GR = 12; ELSE
IF velocity < 325 then Velocity_GR = 13; ELSE
IF velocity < 350 then Velocity_GR = 14; ELSE
IF velocity < 375 then Velocity_GR = 15; ELSE
IF velocity < 400 then Velocity_GR = 16; ELSE
IF velocity < 425 then Velocity_GR = 17; ELSE
IF velocity < 450 then Velocity_GR = 18; ELSE
IF velocity < 475 then Velocity_GR = 19; ELSE
IF velocity < 500 then Velocity_GR = 20;
ELSE Velocity_GR = 21;
RUN;

proc format;
value velocity_gr
1 = "Less than 25"
2 = "25 to 49"
3 = "50 to 74"
4 = "75 to 99"
5 = "100 to 124"
6 = "125 to 149"
7 = "150 to 174"
8 = "175 to 199"
9 = "200 to 224"
10 = "225 to 249"
11 = "250 to 274"
12 = "275 to 299"
13 = "300 to 324"
14 = "325 to 349"
15 = "350 to 374"
16 = "375 to 399"
17 = "400 to 424"
18 = "425 to 449"
19 = "450 to 474"
20 = "475 to 499"
21 = "More than 500";
RUN;

PATTERN1 COLOR=BLUE;
TITLE1 "Velocity";
PROC GCHART DATA=WORK.VELOCITY;
VBAR VELOCITY_GR /	CLIPREF FRAME TYPE=FREQ COUTLINE=BLACK;
format VELOCITY_GR velocity_gr.;
RUN; QUIT;``````

I obtained the following frequency table:

Velocity         N

1                    26

2                    174

3                    371

4                    553

5                    598

6                    581

7                    486

8                    392

9                    311

10                  298

11                  213

12                  151

13                  129

14                  108

15                  76

16                  68

17                  42

18                  41

19                  24

20                  24

21                  67

However, the graph SAS is giving me doesn't reflect neither the format nor the frequency.

Thank you in advance for your help

Accepted Solutions
Solution
‎05-05-2017 11:29 AM
Super User
Posts: 12,148

## Re: PROC GCHART

GCHART will 'pick' values to create bars unless you specify MIDPOINTS on the VBAR statement.

try

VBAR VELOCITY_GR / CLIPREF FRAME TYPE=FREQ COUTLINE=BLACK midpoints= 1 to 20 by 1;

All Replies
Super User
Posts: 8,605

## Re: PROC GCHART

Tip 1, your whole if statements resolve down to:

```data work.velocity;
set work.getnocs;
if noc_open_date=. or noc_close_date=. or first_noc = . then delete;
velocity = noc_close_date-open_date+1;
velocity_gr=velocity/25;
run;```

Tip 2: Gchart is very old.  Better to move to a more recent graphing system - Graph Template Language, Sgplot etc.  You can find plenty of examples here:

http://blogs.sas.com/content/graphicallyspeaking/

Solution
‎05-05-2017 11:29 AM
Super User
Posts: 12,148

## Re: PROC GCHART

GCHART will 'pick' values to create bars unless you specify MIDPOINTS on the VBAR statement.

try

VBAR VELOCITY_GR / CLIPREF FRAME TYPE=FREQ COUTLINE=BLACK midpoints= 1 to 20 by 1;

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
• 2 replies
• 142 views
• 2 likes
• 3 in conversation