Issue with feeding file name into another file

Accepted Solution Solved
Reply
Super Contributor
Posts: 371
Accepted Solution

Issue with feeding file name into another file

[ Edited ]

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;


Accepted Solutions
Solution
‎01-25-2016 04:26 PM
Grand Advisor
Posts: 17,313

Re: Issue with feeding file name into another file

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;

View solution in original post


All Replies
Respected Advisor
Posts: 4,955

Re: Issue with feeding file name into another file

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.

 

 

Super Contributor
Posts: 371

Re: Issue with feeding file name into another file

[ Edited ]

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.

Solution
‎01-25-2016 04:26 PM
Grand Advisor
Posts: 17,313

Re: Issue with feeding file name into another file

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;

Contributor
Posts: 38

Re: Issue with feeding file name into another file

Have you tried it without the %put?

%let datafile=CLEAN_DATA; 
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 312 views
  • 2 likes
  • 4 in conversation