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

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 2404 views
  • 0 likes
  • 4 in conversation