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
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.
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;
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.