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!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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