1
votes

Rather odd problem I've just come across. I'm running the following code in SAS.

data manual_input;
infile datalines dlm=',';
length name $ 32 ;
input name $ varlist_no ;
datalines;
K0002,1
B0000,1
;
run;

When I run this normally in my enhanced editor in Enterprise Guide on our Unix server, it works fine, no problems.

When I run it through a %include statement, as follows:

filename ds_code "/wload/something/something/foo/bar";
%include ds_code ("varlist_input_test.sas") /source2;

The code no longer works. I get errors as follows:

NOTE: Invalid data for varlist_no in line 24 7-80.
RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0                     

24  CHAR   K0002,1.                                                                        
    ZONE   43333230222222222222222222222222222222222222222222222222222222222222222222222222
    NUMR   B0002C1D000000000000000000000000000000000000000000000000000000000000000000000000
name=K0002 varlist_no=. _ERROR_=1 _N_=1
NOTE: Invalid data for varlist_no in line 25 7-80.

25  CHAR   B0000,1.                                                                        
    ZONE   43333230222222222222222222222222222222222222222222222222222222222222222222222222
    NUMR   20000C1D000000000000000000000000000000000000000000000000000000000000000000000000
name=B0000 varlist_no=. _ERROR_=1 _N_=2
NOTE: The data set WORK.MANUAL_INPUT has 2 observations and 2 variables.
NOTE: Compressing data set WORK.MANUAL_INPUT increased size by 100.00 percent. 
      Compressed is 2 pages; un-compressed would require 1 pages.

What gives?! I've specified a comma delimited input. I also understand why datalines wouldn't work within a macro - why would you need to repetitively execute a static dataset input? However, I'd believe it perfectly acceptable to use an include statement to call a piece of code that uses cards/datalines.

Anyone have any ideas?

1

1 Answers

1
votes

Looks like you have an EOL (end-of-line) character that is hanging out in your %included file. Likely you created the include file in Windows (CR/LF EOL characters) and are %including it in Unix (LF only), so the CR character is still there but not treated as part of the end-of-line terminator.

You need to either create this file in Unix, or transfer it properly (with an intelligent FTP program that knows to fix the line terminator), or remove it yourself (COMPRESS with the optional third argument 'C' will do it).

You can also fix this with the TERMSTR option on filename or %include. For example, I can reproduce your error intentionally here (assume test_include.sas has your code in it):

filename testincl "c:\temp\test_include.sas" termstr=LF;
%include testincl;

And you can reverse this:

filename testincl "c:\temp\test_include.sas" termstr=CRLF;
%include testincl;