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!

sas-innovate-2024.png

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.

 

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
  • 4 replies
  • 750 views
  • 0 likes
  • 3 in conversation