06-25-2015 06:20 PM
I created a text file, but for some reason, the headers return when they should be in one row.for example:
the header should be:
A B C D E F G H
but the flat file I have returns:
A B C D E
F G H
I did notice, I got a warning saying:
"WARNING: The quoted string currently being processed has become more than 262 characters long.
You may have unbalanced quotation marks."
Does this cause the problem? If so, how can I fix it?
Here is my program:
proc contents data = file noprint
out = get_varname(keep=name rename=(name=varname));
Proc sql noprint;
select varname into: Flat_head_str separated by '|'
select varname into: Flat_var separated by ' '
FILENAME flatout "C:\SAS\test.txt";
SET file END=EOF;
FILE FLATOUT DELIMITER='|' DSD;
IF _N_=1 THEN PUT "&Flat_HEAD_STR.";
IF EOF THEN PUT "TOTAL NUMBER OF RECORDS = " _N_;
06-25-2015 06:33 PM
What program did you use to look at the resulting file? Notepad, Wordpad, Word and many other text programs will display text wrapped when the line gets to a certain length. Try looking using Notepad and set the Format -> Word wrap off by unchecking.
you might find it easier to use:
proc export data=datasource outfile=fileref dbms=dlm ;
And skip the whole proc contents and macro variables bits.
I realize that you are adding a line with the number of records to the bottom but a specific delimited file makes me think this is for data interchange of some sort and lines with the number of records at the end are exceptions to the column data layout and tend to add extra processing to handle.
Need further help from the community? Please ask a new question.