BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASdevAnneMarie
Barite | Level 11
Thank you very much for your quick answer.
I can’t understand just how «  Otherwise it writes a pipe character to replace the end of line that is going to be removed. » : ) For other points it’s OK, I understood.
Thank you very much!
Tom
Super User Tom
Super User

Here is the step:

data _null_;
   infile original dsd truncover lrecl=32767;
   file fixed lrecl=1000000;
   input line :$char32767. ;
   if notdigit(scan(line,1,','))
      and length(scan(line,1,','))>12 then put '|' @;
   else put;
   len=lengthn(line);
   put line $varying32767. len @;
run;

The IF/THEN/ELSE is what is deciding whether or not to write an end of line.  When the condition is true it writes the | without writing an end of line.  Otherwise it writes just the end of line.  Then it writes the current line it just read, but without an end of line.  The trailing at sign on the PUT statement is what stops it from writing the end of line. Note that the last line written by a data step will automatically get an end of line added.

 

The test in the IF statement is checking whether the beginning of the current line (up to the first comma) does NOT look like a valid value for your first column.  This is the most likely place where you might need to adjust the logic for a different version of the file.

SASdevAnneMarie
Barite | Level 11
Thank you for your quick answer, Tom!
This what I supposed: with the null put I continue writing on the line that is being held by a previous PUT statement with a trailing @ (in case of nodigit values on the beginnig of line).

Yes, thank you, I see, I'm going to replace length(scan(line,1,','))>12 by length(scan(line,1,','))>3, beacause I have a shorter words in other files.
Sorry for disturbing with all my questions :slightly_smiling_face:
Have a nice day!
Marie

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 17 replies
  • 6206 views
  • 2 likes
  • 2 in conversation