hi All, i'm in truble subtracting "date" (from %Let) with another "date" field....
following is showed the code definition...
%let rundt = %sysfunc(date(),date9.)
---
---
select
663 NDG_OPERATORE_ECONOMICO,
664 COD_TIPO_ORG,
665 COD_FORMA_GIURIDICA,
666 DTA_NAS,
667 rundt. - DTA_NAS as delta_date,
-
22
668 case when rundt. - DTA_NAS >= 540 then 'NO_Start_UP'
-
22
ERROR 22-322: Syntax error, expecting one of the following: un nome, *.
669 else 'SI_Start_UP'
670 end AS Start_UP
671
672
673 FROM ANGRFC.ANA_OPERATORE_ECONOMICO
674 GROUP BY 1,2,3,4,5
-
thank's in advance for your support and suggestions
Pio Piccinin
You need to look at what Base SAS code is generated from the find/replace macro system. There are also some issues with your code (which you have not supplied). So you create a text macro variable with the string 13DEC2018, this then goes into your actual code ti form the line:
13DEC2018 - DTA_NAS as delta_date,
As you can clearly see that is not valid Base SAS code. To rectify this you would put the string between quotes, and put a d after it to use SAS implicit date conversion, something like:
"&rundt."d - DTA_NAS as delta_date,
Also, you are missing a semicolon after the end of the %let. And do avoid coding all in shouting case, it makes reading the code so much harder!
Try this code for reference:
%let rundt=%sysfunc(today());
data test;
value = today() -5;
result = &rundt. - value;
format value yymmddd10.;
run;
proc print data=test noobs;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.