BookmarkSubscribeRSS Feed
bbrooke
Fluorite | Level 6

Should I be able to use a picture format in SGPLOT?

 

I created a picture format using a date directive for the week number ('%W').

 

When I generate a scatter plot using PROC SGPLOT, the x-axis tick labels are rendered as %W instead of 01, 02, 03, etc.

 

However, if I use my picture format with PROC GPLOT, the x-axis tick labels are displayed correctly.

 

(I'm familiar with the weekw3. format, but I don't want the extra 'W' in front of every value in my x-axis -- W01, W02, W03, etc.  And I need to use some specific features of SGPLOT rather than reverting to GPLOT.)

 

I found a few other posts on this topic, but the suggested workaround is to convert the x-axis variable to a formatted character value.  I don't think my irregularly-spaced time series data will be plotted correctly if I convert all the dates to formatted characted values.

 

Related Post #1

 

* Related Post #2

 

Does anyone have any insights about using picture formats in PROC SGPLOT?

 

Thanks in advance...

4 REPLIES 4
arodriguez
Lapis Lazuli | Level 10

Hi, 

I don't know if it's a proper solution, but you always could extrat your TPL code from the SGPLOT (option TMPLOUT) and edit the layout XAXISOPTS with something like that if you know the number of weeks.

Layout overlay / XAXISOPTS= (LINEAROPTS=(tickvaluelist=(1 2 3) 
                         tickdisplaylist=('01' '02' '03')))

 

PGStats
Opal | Level 21

@Jay54, Function-formats (fcmp) don't work with sg procs either. 

 



proc fcmp outlib=work.fcmp.fmt;
   function weekfmt(date) $2;
      return(put(week(date),z2.0));
   endsub;
run;

options cmplib=(work.fcmp);

proc format; 
   value weekfmt 
         other=[weekfmt()]; 
run;

/* Doesn't work */
proc sgplot data=sashelp.Citiday;
format date weekfmt.;
series x=date y=SNYDJCM;
run;

/* But this works */
proc print data=sashelp.citiday(obs=20); 
format date weekfmt.; 
run;
PG
PGStats
Opal | Level 21

You could get away with something like this, I guess

 


data myGraph;
set sashelp.Citiday;
/* Weeks starting on a Sunday */
myDate = intck("DAY", "27DEC1987"d, date) / 7; 
format mydate z3.0;
run;

proc sgplot data=myGraph;
series x=mydate y=SNYDJCM;
xaxis integer label="Week Number";
run;
PG

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2072 views
  • 0 likes
  • 4 in conversation