I created this macro:
%LET date = %SYSFUNC(today());
%LET startmonth = %STR(%")%SYSFUNC(intnx(month,&date,-6),yymmn6.)%STR(%");
%LET endmonth = %STR(%")%SYSFUNC(intnx(month,&date,-4),yymmn6.)%STR(%");
%PUT &startmonth &endmonth;
I want to the variable YearMonth to fall in between my startmonth and endmonth macros. Using the below statement gives me the error: Expression using IN has components that are of different data types. YearMonth is (float,null).
PROC SQL;
CREATE TABLE Policy AS
SELECT
A.Policy,
A.PlanCode,
A.I_EmpID,
A.YearMonth
FROM
TestData A
WHERE
A.System = 'NPS'
AND DistributionChannel = 'Direct'
AND "&startmonth" <= YearMonth <= "&endmonth"
;
QUIT;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.