BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Belle
Obsidian | Level 7

Hello,

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));

run;

Proc sql noprint;

  select varname into: Flat_head_str separated by '|'

  from get_varname;

  select varname into: Flat_var separated by ' '

  from get_varname;

FILENAME flatout "C:\SAS\test.txt";

data _NULL_;

  SET file END=EOF;

  FILE FLATOUT  DELIMITER='|' DSD;

  IF _N_=1 THEN PUT "&Flat_HEAD_STR.";

  PUT &flat_var.;

  IF EOF THEN PUT "TOTAL NUMBER OF RECORDS = " _N_;

RUN;

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Is your LRECL too short to include all of the column headers?

Try adding LRECL= option to your FILE statement.

View solution in original post

3 REPLIES 3
ballardw
Super User

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 ;

delimiter='|';

run;

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.

Tom
Super User Tom
Super User

Is your LRECL too short to include all of the column headers?

Try adding LRECL= option to your FILE statement.

Belle
Obsidian | Level 7

Thanks Tom. It works.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1042 views
  • 0 likes
  • 3 in conversation