BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
nbauer1201
Calcite | Level 5

I'm receiving an error pertaining to variables that I thought I had covered. I am a novice at writing SAS and would appreciate any help I can get. Here is the code that I wrote and the associated error message. Thanks in advance for your help!!!

data rats;

length treatment $ 8;

input time event $treatment;

datalines;

18    1    Group0        23    1    Group0

25    1    Group0        26    1    Group0

29    0    Group0        30    1    Group0

30    1    Group0        31    1    Group0

31    0    Group0        32    0    Group0

13    1    Group1        13    1    Group1

15    1    Group1        17    1    Group1

17    0    Group1        18    1    Group1

18    1    Group1        21    1    Group1

23    1    Group1        23    0    Group1

24     1    Group1        25    1    Group1

25    1    Group1

;

ods graphics on;

proc lifetest data=rats atrisk conftype=asinsqrt

    plots=(survival(cb=ep atrisk) loglogs logsurv);

    time time*event(0);

    strata treatment;

run;

ods graphics off;

42     ods graphics on;
43     proc lifetest data=rats atrisk conftype=asinsqrt
44    plots=(survival(cb=ep atrisk) loglogs logsurv);
45    time time*event(0);

ERROR: Variable event in list does not match type prescribed for this list.

46    strata treatment;
47     run;

Thanks again,

Nathan

1 ACCEPTED SOLUTION

Accepted Solutions
dkb
Quartz | Level 8 dkb
Quartz | Level 8

On an list-style input statement, it says that the preceding variable is a character variable.


But since SAS already knows that treatment is a character variable - you've told it in the previous line...

length treatment $ 8;

... you don't need to use $ at all in your input statement.  This will work fine:


data rats;

length treatment $ 8;

input time event treatment;

datalines;

18    1    Group0

...



View solution in original post

4 REPLIES 4
dkb
Quartz | Level 8 dkb
Quartz | Level 8

What do you think the $ does in this line?

input time event $treatment;

nbauer1201
Calcite | Level 5

Doesn't the $ tell sas that it is a character value?

dkb
Quartz | Level 8 dkb
Quartz | Level 8

On an list-style input statement, it says that the preceding variable is a character variable.


But since SAS already knows that treatment is a character variable - you've told it in the previous line...

length treatment $ 8;

... you don't need to use $ at all in your input statement.  This will work fine:


data rats;

length treatment $ 8;

input time event treatment;

datalines;

18    1    Group0

...



nbauer1201
Calcite | Level 5

I can't thank you enough! That absolutely fixed it!!!! It ran with no problems. I was clearly being redundant.

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore 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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 4 replies
  • 5487 views
  • 0 likes
  • 2 in conversation