Hello
I am trying to create a parameter of a date value and use it to take all rows with date higher than 01Apr2017.
Can anyone please explain why it is not working and what is the correct code?
Thanks a lot
data aaa;
length LOC_ID $8 Date Demand 8;
LOC_ID = "C1";
demand = 0;
do Date = '01JAN2017'd to '30JUN2017'd;
output;
end;
run;
Also, your second data step is redundant. Simple use the FORMAT Statement in your first data step.
sorry.Here is the code.Why is it no working?
data aaa;
length LOC_ID $8 Date Demand 8;
LOC_ID = "C1";
demand = 0;
do Date = '01JAN2017'd to '30JUN2017'd;
output;
end;
run;
data bbb;
set aaa;
format Date date9.;
run;
%let monParam='01Apr2017'd;
Data Want;
SET bbb;
IF Date>&monParam.;
Run;
I get no errors from running the code.
Please post your log and what yoy consider "not working".
Sorry.You are right. I run it again and it is working.Thank you anyway
Also, your second data step is redundant. Simple use the FORMAT Statement in your first data step.
Please define "not working". After tidying up your code and dropping the unnecessary datastep the code works perfectly:
data aaa; length loc_id $8 date demand 8; loc_id="C1"; demand=0; do date='01JAN2017'd to '30JUN2017'd; output; end; format date date9.; run; %let monparam='01Apr2017'd; data want; set aaa; if date > &monParam.; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.