Reeza,
I would like to be able put a -1 or so where I can check a date less than today:
%if &date_to = %sysfunc(today()) %then %do;
%if &date_to = %eval(%sysfunc(today()) - 1) %then %do;
Wrap it in %EVAL() to tell SAS to evaluate the value. You can also use INTNX() but in this case subtracting one is easy enough.
@Ivc wrote:
Reeza,
I would like to be able put a -1 or so where I can check a date less than today:
%if &date_to = %sysfunc(today()) %then %do;
@Ivc wrote:
Reeza,
I would like to be able put a -1 or so where I can check a date less than today:
%if &date_to = %sysfunc(today()) %then %do;
What type of value did you put into the macro variable DATE_TO? If it is an integer value then the implied %EVAL() that %IF will use to evaluate the condition will work. But if DATE_TO has a date literal, like '01AUG2019'd then you will need to use %SYSEVALF() to make the comparison.
%let date_to="28JUL2019"d ;
%if %sysevalf(&date_to = (%sysfunc(today())-1) ) %then %do;
Tom,
The date is in this format:"20190726"
@Ivc wrote:
Tom,
The date is in this format:"20190726"
That is NOT a date. That is either an 8 character string that starts with the digit 2 or the number 20,190,726, depending on exactly how you have it.
If you want to convert it to a date then use the INPUT() , or INPUTN(), function with the YYMMDD informat.
Tom,
It is a string of 8 characters that signify the date for our purposes(the source system provides it in this format and it has to be exported the same way). I ran your code against the input file and the outcome seems to what I was expecting.
If you're using the code I wrote, it's not. It should be an integer value but not in the format you've shown. Did you check the macro variables values or just the variable value?
@Ivc wrote:
Tom,
The date is in this format:"20190726"
there should be a pattern to the file being updated. Is the task that needs to be ran monthly, daily, hourly? Please be kind to the network interruptions you impose on your companions? It sounds like a job scheduler task to me.
That is one ugly data step. Looks like it was generated by PROC IMPORT.
You can use the optional CANCEL option on the RUN statement prevent the data step from running. That way you can control wheter it runs without having to learn how to generate code conditionally.
Just read enough of the file to check it you want to really read it or not and set a macro variable. Might be best to make the default be to NOT run the step and only run it when the file pases the test. Then an empty file will not try to be read.
filename ameritot '\\nyadpam\nyadpam_d\apps\CWA_Bondedge_INTMUTUALAMERI_TOT\Bondedge_upload_INTMUTUALAMERITOT.csv';
%let run_cancel=CANCEL ;
data _null_;
infile ameritot firstobs=2 obs=3 dsd ;
input date_to :$10. ;
if input(date_to,??anydtdte.) = today() then call symputx('run_cancel',' ');
run;
data bondedge_upload_tot;
infile ameritot dsd truncover firstobs=2 ;
length Date_To $10 CUSIP $14 Market_Price $10 Portfolio $21
Orig_Face $17 Actual_Par $18 Book_Price $10 Security_Type_Description $14
;
input Date_To -- Security_Type_Description;
run &run_cancel ;
Tom,
I now tested your codes and it seems to be providing the results I am expecting. I will now try to understand the coding. Thanks.
Tom,
What function does '--' do in this line:?
input Date_To -- Security_Type_Description;
Tom,
Thanks for the education on the hyphen.
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.