05-24-2012 01:17 AM
I had a couple of questions around ASCII file:
Any help will be appreciated! Thanks!
05-24-2012 10:34 AM
I don't understand what you mean by blocks of variables but you can on an input statement use things like:
input Var1-var500 Varb1-Barb500;
Which will read the data into Var1 var2 var3 var4 ... var500 Varb1 Varb2 Varb3 .... Varb500
PROC EXPORT has minimal control over output, one it doesn't is variable order on export. You are getting tabs because you requested them in the DBMS=tab statement.
The old school to give you complete control over output to ascii is to use a data _null_, file and put statements. If you want to create fixed column output then there are ways using column pointers to specify either absolute or relative spacing between variables, which formats to use to control appearance of values in the output.
file "C:\my text file.txt" lrecl=<a value at least as large as the number of columns you expect>;
put var1-var500 ;
05-25-2012 09:06 AM
In addition to the response above, you can provide a little more detail. For example, when reading data into SAS from ASCII, you can use the LENGTH statement:
LENGTH V1-V500 $6 V501-V700 8 V701-V900 $1;
You can control the delimiter for the input or output file by using the DLM option:
FILENAME TEXT "my documents\stuff\things.txt";
INFILE TEXT DLM="|" DSD LRECL=9999 MISSOVER;
DLM tells SAS what to use as a separator; DSD tells SAS that consecutive separators imply a missing value. I always identify the input record length, because early on PC-SAS defaulted to (I seem to recall) 256 characters.
You can use the DLM option on your FILE statement as well. As ballardw notes, you need to specify some LRECL value if you expect a long file.
You can also create a fixed-format file by using variations on the PUT statement, e.g.,
FILE "MY DOCUMENTS\TEXT_STUFF.TXT" LRECL=999;
PUT @1 ID