A raw data set is also referred to as a text, ASCII or flat file. Save the data as a text file. Be sure that spaces between variables are blank spaces and NOT TABS.
Use the FILENAME statement to create a fileref (file reference) for the data file. This statement will tell SAS the path to find the external file containing the data.
Then use the fileref in the INFILE statement. The INPUT statement will tell SAS how to read the file. List the variable names after the INPUT statement in the same order they appear in the raw data file. If a character (not numeric), use the"$" sign. See sample below.
title 'Reading raw data file'; option source; /* Convert text file into SAS file */ data work.tickers; length ticker $4; infile './tickers.txt'; input ticker $ compname $ year inducode; run; /* Print the file to make sure read correctly */ proc print data = work.tickers; title 'SAS data set Tickers'; run;
Comments
0 comments
Please sign in to leave a comment.