I have a SAS code which will refer to a formula stored in external text file.
input data:
x | y |
10 | 67 |
15 | 70 |
30 | 71 |
output data:
x | y | z |
10 | 67 | 77 |
15 | 70 | 85 |
30 | 71 | 101 |
Written SAS Code:
data want;
set have;
%include "path/file_ln_model.txt";
run;
Text file (file_ln_model.txt):
z= x+y;
This above sas code throws the following error:
27 +z=x+y;
_____________
180
ERROR 180-322: Statement is not valid or it is used out of proper order.
Please help to find the error in this code and provide any alternative situations.
Thanks in advance.
To me it looks like your file does not contain "z= x+y;", but "+z= x+y;". You can check what you %INCLUDE by using the SOURCE2 option:
data want;
set have;
%include "path/file_ln_model.txt" /source2;
run;
To me it looks like your file does not contain "z= x+y;", but "+z= x+y;". You can check what you %INCLUDE by using the SOURCE2 option:
data want;
set have;
%include "path/file_ln_model.txt" /source2;
run;
There seems to be a preceding plus sign in your .txt file. Your code looks fine.
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.