Hi All, Please help me... I am looking for a solution to a very basic problem. I am new to SAS and don't use it too often, so get quite tied up in the formatting. I have a check I'd like to do whereby I check a prompt date (Cut_off_date_prompt is currently same as Cutoff_Date) against another date and abort/cancel if the two are different. Forgive me if my code is terrible. Program code is below, excerpt of the log below that. My prompt works fine, as does the conversion. FM variable is returning NOV60 not MAR21. I am assuming this is because it is reading this as a number, but am unsure how to convert that to a date? PROGRAM %let Cutoff_Date = '01Mar2021'd ; %put &Cutoff_Date; %let fileyear = 2021; %let filemonth = 0321; %let prevfileyear = 2021; %let prevfilemonth = 0221; %let CoDP = %sysfunc(inputn(&cutoff_date_prompt,date9.),monyy.); %let FM = %sysfunc(inputn(&filemonth,MMYYn4.),monyy.); %put &CoDP; %put &FM; %macro datecheck; %if &CoDP ne &FM %then %abort cancel; %mend; LOG 20 NOGTITLE
21 NOGFOOTNOTE
22 GPATH=&sasworklocation
23 ENCODING=UTF8
24 options(rolap="on")
25 ;
26
27 GOPTIONS ACCESSIBLE;
28
29 %let Cutoff_Date = '01Mar2021'd ;
30 %put &Cutoff_Date;
'01Mar2021'd
31
32 %let fileyear = 2021;
33 %let filemonth = 0321;
34 %let prevfileyear = 2021;
35 %let prevfilemonth = 0221;
36
37 %let CoDP = %sysfunc(inputn(&cutoff_date_prompt,date9.),monyy.);
38
39
40 %let FM = %sysfunc(inputn(&filemonth,MMYYn4.),monyy.);
41
42 %put &CoDP;
MAR21
43 %put &FM;
NOV60
44
45 %macro datecheck;
46 %if &CoDP ne &FM %then
2 The SAS System 12:21 Thursday, March 4, 2021
47 %abort cancel;
48 %mend;
49
50 %put _user_; Please help! Thanks. Greedy
... View more