Hi Everyone,
I have 2 SAS code. Code 1 is to process data. At the end of Code 1. I get the final/clean data named CLEAN_DATA.
For analysis purpose (say Proc means...), I put them all in Code 2.
This will make my code easy to follow.
At the end of code 1, I call "code 2.sas" using the few line below;
----------------------------------------------------------------------------------------------------------------
filename w3 temp;
data _null_;
file w3;
put '%let ' datafile="CLEAN_DATA" ';' *when I use datafile=CLEAN_DATA without quote, still not work;
/ '%include "C:\Users\HPNEW\Dropbox\SAS\CODE 2.sas" ;'
;
run;
%include w3 / source2 ;
----------------------------------------------------------------------------------------------------------------
Code 2 is
proc sort data=&datafile;by date;run;
proc means data=&datafile noprint;
by date ;
var var1 var2.....
---------------------------------------------------------------------------------------------------------------------
It doesnt works.
Could you help me to fix it or suggest a method that works?
Thank you for your help.
HHC
The error notice is:
NOTE: Line generated by the macro variable "DATAFILE".
1 . CLEAN_DATA
-
22
200
ERROR 22-322: Expecting a name.
ERROR 200-322: The symbol is not recognized and will be ignored.
**************************************************************SOLUTION*****************************************
%let datafile1=Buy_signal;
%let datafile2=Sell_signal;
%include "C:\Users\HPNEW\Dropbox\SAS\return_report_1.sas" /lrecl=500;
run;
Check the length of the line of code in your programs.
Try adding the LRECL= option to the end of your include statement.
%include 'filename.sas' /lrecl=500;
It looks like you could simplify the program considerably. Try it this way:
%let datafile=CLEAN_DATA;
%include "C:\Users\HPNEW\Dropbox\SAS\CODE 2.sas" ;
The rest wouldn't be needed.
Good luck.
It works correctly as it call the program and run but it causes another issue that I countered when playing around with the original code.
Some how it create the below warning and suprisingly, there is no BUY_TYPE_RR10 variable in my list
the name of variables are BUY_TYPE_RR10_sl123, BUY_TYPE_RR10_sl234
I suspect that the Truncation cause this problem.
If I run the code manually, there is no warning at all.
This warning appear when I do the PROC MEANS
WARNING: Truncated record.
ERROR: Variable BUY_TYPE_RR10 not found.
NOTE: The SAS System stopped processing this step because of errors.
Check the length of the line of code in your programs.
Try adding the LRECL= option to the end of your include statement.
%include 'filename.sas' /lrecl=500;
Have you tried it without the %put?
%let datafile=CLEAN_DATA;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.