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

I'm getting multiple occurrences of the same variable (month) on my x-axis in GCHART. However when I run the Proc Freq, it shows that that each month is discrete. I've attached the output for GCHART and for FREQ. The code is below. Thanks for your help! Proc Freq data=All2 ; Tables Month / nocol norow missing ; Run ; Proc GCHART data=All2 ; vbar Month / type = freq ; Run I'm getting multiple occurrences of each monthI'm getting multiple occurrences of each monthProc freq shows the months as discreteProc freq shows the months as discrete

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

If you're using Proc GChart, try adding the 'discrete' vbar option.

If that doesn't work, then try also adding the 'nozero' vbar option.

View solution in original post

4 REPLIES 4
ballardw
Super User

I suspect that you have actual dates with different days of the month and a MONYY7 format applied. Gchart will attempt, depending on your Proc and Axis options attempt to display tick marks for separate values but with the same format they get the same label.

Proc freq however honors the format for grouping purposes.

 

You should show your entire output proc chart code and any associated AXIS, SYMBOL and PATTERN statements.

 

Here is an example of Proc Freq reporting different days of the month as a single "month" for the output.

data example;
   input x mmddyy10.;
   format x date9.;
datalines;
02/01/2018
02/02/2018
;
run;

proc freq data=example;
  tables x;
  format x monyy7.;
run;

/* with default format*/
proc freq data=example;
  tables x;
run;
NancyBerkley
Fluorite | Level 6

I thought of this, but I am creating the date variable myself from an Excel Data/Time String...

 

Session Start
2018-01-02 08:14:00
2018-01-02 08:26:03
2018-01-02 09:47:01

 

Data Test1 ; Set Usage.All_Data ;

Start_Year_Str = Substr(Session_Start,1,4) ;

Start_Year = input(Start_Year_Str, 8.) ;

Start_Month_Str = Substr(Session_Start,6,2) ;

Start_Month = input(Start_Month_Str, 8.) ;

Start_Date = MDY(Start_Month,1,Start_Year) ;

Format Start_DAte MonYY7. ;

Run ;

 

Output:

Session_Start Start_Year_Str Start_Year Start_Month_Str Start_Month Start_Date
2018-01-02 08:14:00 2018 2018 01 1 JAN2018
2018-01-02 08:26:03 2018 2018 01 1 JAN2018
2018-01-02 09:47:01 2018 2018 01 1 JAN2018
2018-01-02 10:01:37 2018 2018 01 1 JAN2018
2018-01-02 13:31:39 2018 2018 01 1 JAN2018

 

Using the option Discrete as recommended by RobertAllison_SAS did the trick.                   

GraphGuy
Meteorite | Level 14

If you're using Proc GChart, try adding the 'discrete' vbar option.

If that doesn't work, then try also adding the 'nozero' vbar option.

NancyBerkley
Fluorite | Level 6
"Discrete" did the trick. Thanks so much!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1493 views
  • 0 likes
  • 3 in conversation