BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Norman21
Lapis Lazuli | Level 10

Hi,

 

I have a text file with a repeating structure, and am having difficulty importing it using either infile or proc import. Each line ends with a CR LF.

 

This is what I have:

first line (to be skipped)

<blank>

1

10:02:03

some text, that might contain commas or semicolons

<blank>

2

10:02:04

some more text

<blank>

3

10:02:07

yet more text

 

etc.

 

This is what I want:

Var1   Var2          Var3

1         10:02:03   some text, that might contain commas or semicolons

2         10:02:04   some more text

3         10:02:07   yet more text

etc.

 

This should be simple but it has me stumped! Can anyone help?

 

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User
data want;
infile "yourfile" termstr=CRLF truncover;
input; /* skips blank line */
input var1; /* numeric */
input var2 time8.; /* time */
format var2 time8.;
input var3 $100.; /* text, adapt length to maximum expected */
run;

This will work as long as the 4-line sequence is reliably kept; if the sequence might change, further measures are necessary.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User
data want;
infile "yourfile" termstr=CRLF truncover;
input; /* skips blank line */
input var1; /* numeric */
input var2 time8.; /* time */
format var2 time8.;
input var3 $100.; /* text, adapt length to maximum expected */
run;

This will work as long as the 4-line sequence is reliably kept; if the sequence might change, further measures are necessary.

Norman21
Lapis Lazuli | Level 10

Multiple INPUT statements! That never occurred to me.

 

KurtBremser, your solution worked after one minor modification (adding firstobs=2 to the infile statement).

 

Thanks a million!

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1032 views
  • 1 like
  • 2 in conversation