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
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
...
What do you think the $ does in this line?
input time event $treatment;
Doesn't the $ tell sas that it is a character value?
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
...
I can't thank you enough! That absolutely fixed it!!!! It ran with no problems. I was clearly being redundant.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.