BookmarkSubscribeRSS Feed
Harbour12345
Calcite | Level 5

Hi,

I'm new to the SAS and have trouble running this code:

data easyway;
  do Group = 'Placebo','Active';
    do Subj = 1 to 5;
      input Score @;
      output;
    end;
  end;
datalines;
250 222 230 210 199
166 183 123 129 234
;

 

This is an example from Ron Cody's book of "Learning SAS by Example", Program 8-12. Any comments are greatly appreciated.

3 REPLIES 3
mklangley
Lapis Lazuli | Level 10

That code runs fine for me. What issue are you running into? Is there an error?

Harbour12345
Calcite | Level 5
thanks for reply. Somehow it works fine after rebooting the program and computer. 🙂
ballardw
Super User

When you get an error or questionable message in the log, please copy the data step or procedure along with any messages from the LOG and post them in the code box.
Then you can reference your explicit question. The code you provided does not generate an error for me but does have a NOTE (which very specifically is not an error) that you might not expect.

 

You might want to add an explicit Input to advance to the next line when expected:

data easyway;
  do Group = 'Placebo','Active';
    do Subj = 1 to 5;
      input Score @;
      output;
    end;
    input;
  end;
datalines;
250 222 230 210 199
166 183 123 129 234
;

That will get rid of the note:

NOTE: SAS went to a new line when INPUT statement reached past the end of a line.

It is usually a good idea to use an explicit input to stop the @; reading when you know you  have read the expected data.

If you have more complex input file then this can be critical to control where and when values get read.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

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