BookmarkSubscribeRSS Feed
ariel_fj
Fluorite | Level 6

What's wrong with my do loop code?

"

data readsp;
do Method = 'A','B','C';
  do Subj = 1 to 10;
     input Score @;
     output;
  end;
end;
datalines;
250 255 256 300 244 268 301 322 256 333
267 275 256 320 250 340 345 290 280 300
1 2 3 4 5 6 7 8 9 0

;

title "List of Speed-reading Methods Test";
proc print data=readsp noobs;
run;

"

the output can only show these:

"

Method    Subj    Score

C         8       8
C         9       9
C        10       0            “

Where are the others?

2 REPLIES 2
Tom
Super User Tom
Super User

You do not tell it to goto the next line when it has finished reading the 10 values.

Add an INPUT statement after the inner loop.

data readsp;
do Method = 'A','B','C';
  do Subj = 1 to 10;
     input Score @;
     output;
  end;

   input;
end;
datalines;
250 255 256 300 244 268 301 322 256 333
267 275 256 320 250 340 345 290 280 300
1 2 3 4 5 6 7 8 9 0

;

Ksharp
Super User

you should add double @ to prevent point to skip to next line at next data step iteration.

data readsp;
do Method = 'A','B','C';
  do Subj = 1 to 10;
     input Score @@;
     output;
  end;
end;
datalines;
250 255 256 300 244 268 301 322 256 333
267 275 256 320 250 340 345 290 280 300
1 2 3 4 5 6 7 8 9 0
;

title "List of Speed-reading Methods Test";
proc print data=readsp noobs;
run;









Ksharp

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 818 views
  • 6 likes
  • 3 in conversation