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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: