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

I run a program that gives me different results based on specific parameters.

 

I then use PROC SQL with the INTO clause to create macro variables based on those results. One of the variables created is the numerical date value from a data set. This is, of course, stored as a character variable when the macro vaariable is created.

 

I then want to create a number of time-series plots with SGPLOT. I'd like to use the value of those date macro variables in the creation of the plots where the extracted date value is resolved in the SGPLOT procedure.

 

For example,

 

%let Date=17543

proc sgplot data=uscpi;
      series x=date y=cpi / markers;
      format date yyqc.;
      xaxis values=("&date"d to "1jul10"d by qtr);
run;

Is there a decent way to resolve a macro variable in this fashion?

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

If 17543 is the SAS date value you want (number of days since 1/1/1960).  Then you could do:

%let date=17543;
...
xaxis values=(&date to "1jul10"d by qtr);

 

 

You only use the quotes with the d suffix when you want to indicate a date literal.  So you could do:

 

%let date=03Apr2000;
...
xaxis values=("&date"d to "1jul10"d by qtr);
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

View solution in original post

1 REPLY 1
Quentin
Super User

If 17543 is the SAS date value you want (number of days since 1/1/1960).  Then you could do:

%let date=17543;
...
xaxis values=(&date to "1jul10"d by qtr);

 

 

You only use the quotes with the d suffix when you want to indicate a date literal.  So you could do:

 

%let date=03Apr2000;
...
xaxis values=("&date"d to "1jul10"d by qtr);
BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

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
  • 1 reply
  • 797 views
  • 0 likes
  • 2 in conversation