BookmarkSubscribeRSS Feed
cho16
Obsidian | Level 7

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

8 REPLIES 8
Tom
Super User Tom
Super User

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.

cho16
Obsidian | Level 7
Tom...Below I have provided some additional details..
Can we add a flag that says "Y" or "N"? If changes need to be made, set the flag to "Y" and start the process. If not, the procedure shouldn't start.
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;
cho16
Obsidian | Level 7
Our organization has a lot of plans. The vendor will put the file in one place if we wish to eliminate one plan from the extract.
For instance, the deconversion is a one-time activity for the August release; the same process should not be followed for the September release; again, the deconversion will occur for the November release; hence, there is no need to modify the SAS code; rather, additional conditions must be included.Hope this helps
Reeza
Super User

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...

cho16
Obsidian | Level 7
Thanks Reeza..we are using SAS EG
Reeza
Super User
Do you want a prompt in the process?
Or set a macro variable at the start of a program?
Do you have a control program where you set parameters?
Or is the status of changes required driven by something in the process?

Either way the macro solution above is how you structure the code. Exactly how you incorporate that into your process depends on your process, which we do not have or understand. You could have a prompt for the parameter instead of the LET for example.
Tom
Super User Tom
Super User

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;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 8 replies
  • 982 views
  • 0 likes
  • 4 in conversation