Hello,
Any methods to reacd external files in SAS except INFILE ??
Would it qualify as not using INFILE if the external file had a "datalines;" statement as its first line. If so, then such a file can be %INCLUDEd (like c:\temp\t.txt below in the second data step.
filename f 'c:\temp\t.txt';
data _null_;
file f;
put 'datalines;';
put '1 1 1';
put '2 2 2';
run;
data t;
input a b c;
%include 'c:\temp\t.txt';
run;
Those who are facile with their operating system commands can probably create a pipe with the "datalines;" statement dynamically inserted before streaming the file in question. Then just %INCLUDE the pipe.
@Aexor wrote:
Hello,
Any methods to reacd external files in SAS except INFILE ??
PROC IMPORT can be used to convert external files into SAS datasets. Check the documentation for the types of files it can read. Typically you use this to convert data that looks like a dataset, like a spreadsheet (Excel files for example), another database (dBASE, SPSS, STATA, etc)
SAS/Access has modules to connect to many data sources.
ODBC can be used to connect to some.
The LIBNAME can also connect to some file types.
Would it qualify as not using INFILE if the external file had a "datalines;" statement as its first line. If so, then such a file can be %INCLUDEd (like c:\temp\t.txt below in the second data step.
filename f 'c:\temp\t.txt';
data _null_;
file f;
put 'datalines;';
put '1 1 1';
put '2 2 2';
run;
data t;
input a b c;
%include 'c:\temp\t.txt';
run;
Those who are facile with their operating system commands can probably create a pipe with the "datalines;" statement dynamically inserted before streaming the file in question. Then just %INCLUDE the pipe.
When reading text files, you will always have an INFILE statement, either written by you or by the IMPORT procedure.
What's so bad about INFILE? Did it bite you?
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: