BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hhchenfx
Rhodochrosite | Level 12

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;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

4 REPLIES 4
Astounding
PROC Star

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.

 

 

hhchenfx
Rhodochrosite | Level 12

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.

Reeza
Super User

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;

DanZ
Obsidian | Level 7

Have you tried it without the %put?

%let datafile=CLEAN_DATA; 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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