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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

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