Hi there,
We aim to add some additional logic to the prod code that already exists. The code should read the text file as though it were a one-time task if any plans needed to be removed from the logic. Otherwise, 0 values must be read from the text file.
Is it possible to add logic to it in any way?
Thanks in advance
Probably since SAS is a programming language.
But you need to provide a lot more information about what you are actually doing and what the terms you are using actually mean.
Explain (in detail!) what you mean by this:
If changes need to be made
and also, what you mean by "process" and "procedure".
What tool are you using? SAS DIS or Studio/Base?
%macro run_report(report_run = );
%if &report_run = Y %then %do;
DATA DE_CONVER_ACTS;
infile "/hf_out.txt" dsd dlm='|' MISSOVER FIRSTOBS=2 end=eof;
length
ACCOUNT$ 16
SYS$ 4
MEMBER$ 4
AGENT$ 4
Date$ 8
;
input
ACCOUNT$
SYS$
PRIN$
MEMBER $
Date$
;
run;
%end;
%mend;
%let changes_required = Y;
%run_report(report_run= &changes_required);
UCLA introductory tutorial on macro variables and macros
https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/
Tutorial on converting a working program to a macro
This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it 🙂 https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md
Examples of common macro usage
https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Ap...
Which variable is the one that indicates if the "process" needs to happen?
None of those variable names look like they could contain that information.
ACCOUNT SYS MEMBER AGENT Date
Or are you saying that the indicator is whether or not there are any records in the file?
DATA DE_CONVER_ACTS;
if eof then call symputx('nobs',_n_-1);
infile "/hf_out.txt" dsd dlm='|' MISSOVER FIRSTOBS=2 end=eof;
...
run;
%if &nobs %then %do;
... process that will be skipped ...
%end;
Or are you saying that the indicator is whether or not there is a file?
%if %sysfunc(fileexist(/hf_out.txt)) %then %do;
... process that will be skipped ...
%end;
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.