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

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
Barite | Level 11

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; 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 646 views
  • 2 likes
  • 4 in conversation