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

Hello,

I've been using the following Proc export statement for one of my projects to get the desired ts and it works great.  However my data only contained one month of data so my ORDER_Date always gave me the appropriate timestamp that I wanted.

Now, I'm pulling multiple months so I have more than one ORDER_Date.  I would like the ts to be the MAX ORDER_Date but I can't seem to get it to work.  Any direction would be appreciated!  thank you!

 Currently:

LRogers_0-1634927021546.png

I tried:

data _null_;

set work.XACTLY (obs=1);
call symput('ts', put(MAX(ORDER_Date), MONYY7.));
run;

but that didn't work.  I also tried creating a new field to reference but that didn't work either.

data _null_;

set work.XACTLY (obs=1);

last_date = MAX(ORDER_Date);
call symput('ts', put(last_date, MONYY7.));
run;

Any suggestions?

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Change how you're creating the macro varaible from data step to SQL.

 

proc sql noprint;
select put(max(order_date), monyy7.) into :ts TRIMMED
from xactly;
quit;

*check macro variable creation;
%put &ts.;

@LRogers wrote:

Hello,

I've been using the following Proc export statement for one of my projects to get the desired ts and it works great.  However my data only contained one month of data so my ORDER_Date always gave me the appropriate timestamp that I wanted.

Now, I'm pulling multiple months so I have more than one ORDER_Date.  I would like the ts to be the MAX ORDER_Date but I can't seem to get it to work.  Any direction would be appreciated!  thank you!

 Currently:

LRogers_0-1634927021546.png

I tried:

data _null_;

set work.XACTLY (obs=1);
call symput('ts', put(MAX(ORDER_Date), MONYY7.));
run;

but that didn't work.  I also tried creating a new field to reference but that didn't work either.

data _null_;

set work.XACTLY (obs=1);

last_date = MAX(ORDER_Date);
call symput('ts', put(last_date, MONYY7.));
run;

Any suggestions?

Thank you!


 

View solution in original post

3 REPLIES 3
Reeza
Super User

Change how you're creating the macro varaible from data step to SQL.

 

proc sql noprint;
select put(max(order_date), monyy7.) into :ts TRIMMED
from xactly;
quit;

*check macro variable creation;
%put &ts.;

@LRogers wrote:

Hello,

I've been using the following Proc export statement for one of my projects to get the desired ts and it works great.  However my data only contained one month of data so my ORDER_Date always gave me the appropriate timestamp that I wanted.

Now, I'm pulling multiple months so I have more than one ORDER_Date.  I would like the ts to be the MAX ORDER_Date but I can't seem to get it to work.  Any direction would be appreciated!  thank you!

 Currently:

LRogers_0-1634927021546.png

I tried:

data _null_;

set work.XACTLY (obs=1);
call symput('ts', put(MAX(ORDER_Date), MONYY7.));
run;

but that didn't work.  I also tried creating a new field to reference but that didn't work either.

data _null_;

set work.XACTLY (obs=1);

last_date = MAX(ORDER_Date);
call symput('ts', put(last_date, MONYY7.));
run;

Any suggestions?

Thank you!


 

LRogers
Obsidian | Level 7
Thank you very much! I definitely wouldn't have been able to come up with this myself nor do i quite understand it...but it worked! haha! Thank you! Much appreciated!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1120 views
  • 2 likes
  • 3 in conversation