BookmarkSubscribeRSS Feed
ZRick
Obsidian | Level 7

data crv4;

input

i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13

    /                                                                   

i2r1 i2r2 i2r3 i2r4 i2r5 i2r6 i2r7 i2r8 i2r9 i2r10 i2r11 i2r12 i2r13;

cards;

4 4.5 5 5.5 6 6.5 7 7.5

8 8.5 9 9.5 10

0.4835 . 0.7335

. . . 1.184 . . . . . 1.64

;

I want to i2r1 and rest of it become 2nd obs, so i will have two lines of obs.

SAS keeps making only 1 line.

how can I correct it?

4 REPLIES 4
SASJedi
SAS Super FREQ

Try reading each line separately with an OUTPUT statement in between.  For example:

data crv4; 
   infile datalines truncover;
   input i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13;
   output;
   call missing (of i1r1--i1r13);
   input i2r1 i2r2 i2r3 i2r4 i2r5 i2r6 i2r7 i2r8 i2r9 i2r10 i2r11 i2r12 i2r13;
   output;
cards;
4 4.5 5 5.5 6 6.5 7 7.5 8 8.5 9 9.5 10
0.4835 . 0.7335 . . . 1.184 . . . . . 1.64
;
run; 
Check out my Jedi SAS Tricks for SAS Users
Ksharp
Super User

The code below is what you need?

data crv4;
infile cards truncover;
input
i1r1 i1r2 i1r3 i1r4 i1r5 i1r6 i1r7 i1r8 i1r9 i1r10 i1r11 i1r12 i1r13 ;
cards;
4 4.5 5 5.5 6 6.5 7 7.5
8 8.5 9 9.5 10
0.4835 . 0.7335
. . . 1.184 . . . . . 1.64
;
run;

Ksharp

ZRick
Obsidian | Level 7

I c, I guess the truncover does the trick, but see following code:

data t;

input

    k1f1    k1f2    k1f3    k1f4    k1f5    k1f6    k1f7    k1f8    k1f9    k1f10

    /                                                                               

    k2f1    k2f2    k2f3    k2f4    k2f5    k2f6    k2f7    k2f8    k2f9    k2f10;

cards;

56.7 58.7 68.3 70.3 61.9 87.6 99.3 65.3 78.3 91.5

88.5 63.9 66.8 77.6 55.9 35.9 54.8 98.6 77.3 68.5

51.6 88.7 79.6 65.9 94.1 91.6 83.6 85.7 66.8 77.9

98.5 79.9 99.9 55.6 68.9 46.8 79.8 88.6 88.8 97.5

;

It does break into two lines too, and didn't use truncover, why is that?

Ksharp
Super User

Because you use / operation which will make pointer to point the next line,

If you need two obs then remove it.

input

    k1f1    k1f2    k1f3    k1f4    k1f5    k1f6    k1f7    k1f8    k1f9    k1f10

                                                                           

    k2f1    k2f2    k2f3    k2f4    k2f5    k2f6    k2f7    k2f8    k2f9    k2f10;

Ksharp

Ksharp

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!

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
  • 4 replies
  • 1066 views
  • 0 likes
  • 3 in conversation