BookmarkSubscribeRSS Feed
ThomasGeorge
Calcite | Level 5

I tried this code:

data Rulan;

length Evaluation $50 Questions $50

input Evaluation $ Questions $ ID SP_MD Response Out_Of;

datalines;

canmed Patients needs and feelings 001 1 5 5

standardized.pt Response to feelings  001 0 6 7

canmed Coherence 001 1 5 5

standardized.pt Degree of coherence 001 0 4 5

canmed Verbal Expression 001 1 5 5

standardized.pt Verbal Expression 001 0 5 5

canmed Non-Verbal Expression 001 1 5 5

standardized.pt Non-Verbal Expression 001 0 4 5

run;

But i get this error:

why?

144  data Rulan;

145  length Evaluation $50 Questions $50

146  input Evaluation $ Questions $ ID SP_MD Response Out_Of;

                        ---------

                        391

                        202

WARNING: Length of character variable Evaluation has already been set.

         Use the LENGTH statement as the very first statement in the DATA STEP to declare the

         length of a character variable.

146  input Evaluation $ Questions $ ID SP_MD Response Out_Of;

                                                            -

                                                            22

ERROR 391-185: Expecting a variable length specification.

ERROR 202-322: The option or parameter is not recognized and will be ignored.

ERROR 22-322: Expecting a numeric constant.

1    1

     -

     352

ERROR 352-185: The length of numeric variables is 3-8.

147  datalines;

NOTE: The SAS System stopped processing this step because of errors.

WARNING: The data set WORK.RULAN may be incomplete.  When this step was stopped there were 0

         observations and 7 variables.

WARNING: Data set WORK.RULAN was not replaced because this step was stopped.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

156  run;

3 REPLIES 3
Haikuo
Onyx | Level 15

For one, you missed a semicolon on the end of your length statement and after your raw data. For two, I see more elements in your raw data than the ones being defined in your input statement. You need to read the manual.

Regards,

Haikuo

Edit: The little SAS book was a good start for me: http://www.amazon.com/dp/1599947250/ref=asc_df_15999472501920882?smid=ATVPDKIKX0DER&tag=hyprod-20&li...

ThomasGeorge
Calcite | Level 5

I tried this code:

data Rulan;

          length Evaluation $ 30. Questions $ 80.;

          input Evaluation $ Questions $ ID SP_MD Response Out_Of;

datalines;

canmed Patients needs and feelings 001 1 5 5

standardized.pt Response to feelings  001 0 6 7

canmed Coherence 001 1 5 5

standardized.pt Degree of coherence 001 0 4 5

canmed Verbal Expression 001 1 5 5

standardized.pt Verbal Expression 001 0 5 5

canmed Non-Verbal Expression 001 1 5 5

standardized.pt Non-Verbal Expression 001 0 4 5

run;

It gives me this info on the log:

1    data Rulan;

2        length Evaluation $ 30. Questions $ 80.;

3        input Evaluation $ Questions $ ID SP_MD Response Out_Of;

4    datalines;

NOTE: Invalid data for ID in line 5 17-21.

NOTE: Invalid data for SP_MD in line 5 23-25.

NOTE: Invalid data for Response in line 5 27-34.

RULE:      ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+--

5          canmed Patients needs and feelings 001 1 5 5

Evaluation=canmed Questions=Patients ID=. SP_MD=. Response=. Out_Of=1 _ERROR_=1 _N_=1

NOTE: Invalid data for ID in line 6 26-27.

NOTE: Invalid data for SP_MD in line 6 29-36.

6          standardized.pt Response to feelings  001 0 6 7

Evaluation=standardized.pt Questions=Response ID=. SP_MD=. Response=1 Out_Of=0 _ERROR_=1 _N_=2

NOTE: Invalid data for ID in line 8 24-25.

NOTE: Invalid data for SP_MD in line 8 27-35.

8          standardized.pt Degree of coherence 001 0 4 5

Evaluation=standardized.pt Questions=Degree ID=. SP_MD=. Response=1 Out_Of=0 _ERROR_=1 _N_=4

NOTE: Invalid data for ID in line 9 15-24.

9          canmed Verbal Expression 001 1 5 5

Evaluation=canmed Questions=Verbal ID=. SP_MD=1 Response=1 Out_Of=5 _ERROR_=1 _N_=5

NOTE: Invalid data for ID in line 10 24-33.

10         standardized.pt Verbal Expression 001 0 5 5

Evaluation=standardized.pt Questions=Verbal ID=. SP_MD=1 Response=0 Out_Of=5 _ERROR_=1 _N_=6

NOTE: Invalid data for ID in line 11 19-28.

11         canmed Non-Verbal Expression 001 1 5 5

Evaluation=canmed Questions=Non-Verbal ID=. SP_MD=1 Response=1 Out_Of=5 _ERROR_=1 _N_=7

NOTE: Invalid data for ID in line 12 28-37.

12         standardized.pt Non-Verbal Expression 001 0 4 5

Evaluation=standardized.pt Questions=Non-Verbal ID=. SP_MD=1 Response=0 Out_Of=4 _ERROR_=1 _N_=8

NOTE: The data set WORK.RULAN has 8 observations and 6 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds

13   run;

art297
Opal | Level 21

I would change the lengths to informats and, instead of the $ signs in the input statements replace them with & as you want to read multiple words, and insure that you have at least two spaces (not the one that you currently have) between variables in your data.

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!

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