11-11-2016 11:24 PM
A customized data step.
You can use use the info from sashelp.vcolumns (length/type/format) to help generate the info required for the code...or even the code.
11-11-2016 11:31 PM
See the example here.
Determining the locations (@#) is based on length which can be obtained from dictionary tables or proc contents.
11-12-2016 01:26 AM
What do you mean by fixed length. Can you post an example ?
filename x 'c:\temp\x.csv' ; data _null_; set sashelp.class; file x ; length temp $ 40; temp=catx(',',of _all_); len=40; put temp $varying40. len; run;
11-12-2016 08:31 AM
I have no idea.. it's a request from someone that it must be fixed length. So here's what I did:
filename out_pipe "P:\Data\new_bo1.txt";
data _null_; set pdrive.new_bor1;
put "|" ACEAmount
11-12-2016 03:51 AM - edited 11-12-2016 03:53 AM
PUT statement default behaviour for a list of variables would place single blanks (default delimiter) between vars.
Consider the brevity of:
FILE "YOUR FILE.CSV" DSD LRECL=1000 ;
PUT (_ALL_)( : ) ;
One way to achieve fixed layout would be to specify the formats with widths for each variable in the PUT.
It makes a fine example for use of the dictionary.columns metadata.
Just one question ... what default format/width would you wish for numeric values with no defined format?
The default BEST12. provides floating point notation for large numeric values.....
Once the required choices of width are clarified, a bit of SQL and a simple data step could be written by a student.
In a fixed layout, delimiters would not be needed, but might reduce any importer's need for proper definition of the column layout.
I believe the fixed positions layout would probably be faster to import than traditional csv ... (less cpu time, but more expensive in disk space and i/o) but any benefit will only become apparent for very large data.
11-12-2016 10:25 AM
Use formatted output
put x1 $10. x2 $20. ;
will result in lines of length 30.