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:
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!
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:
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!
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:
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!
And while you're at it, change the format to YYMMN6. or YYMMD7., which sorts in chronological order and makes handling the files much easier.
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!
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.
Ready to level-up your skills? Choose your own adventure.