Hi there
This is my first post so apologies if I'm missing anything.
I'm doing a survival analysis and one of the tasks I wish to do is to estimate survival curves for males and females after controlling for age. My mean age is 39.93673111.
First I create a dataset of covariate values in the data step. Each row contains a set of covariate values for which I would like a survival plot.
data control;
input Sex$6. Age;
datalines;
Female 39.93673111
Male 39.93673111
;
run;
I thus get a dataset called “control” with 2 rows of covariates
Next, I utilize the following SAS Code to run my plot
proc phreg data = Survival plots(overlay)=(survival);
class Sex;
model Time*Event(0) = Sex Age;
baseline covariates=control out=base / rowid= Sex;
run;
However, I get the following error
"ERROR: Variable Sex in WORK.CONTROL does not have the same format as in the input data."
I checked and my format, Length, and variable type are the same between the "Control" dataset and my "Survival" dataset for Age and Sex.
Is there anything wrong with my code?
Thanks!
I suspect that if you check the properties of the variable in your Survival data set you will find Sex is a numeric variable. Possibly there is format associated with it to display text like Female or Male but the variable is numeric.
If you do not know how to check properties, one way:
Proc contents data=survival;
run;
The results window will show information about the data set and list of variables and the types.
Sure. Here is one for the "Control" dataset
and here is the one for the "Survival" dataset
Sorry, can you run that again with formats stripped? I'm assuming it's a character variable? You can use an 'empty' format statement as below to do this:
proc freq data=have;
table varName;
format _character_;
run;
I suspect that if you check the properties of the variable in your Survival data set you will find Sex is a numeric variable. Possibly there is format associated with it to display text like Female or Male but the variable is numeric.
If you do not know how to check properties, one way:
Proc contents data=survival;
run;
The results window will show information about the data set and list of variables and the types.
Thank you to all who helped steer me in the right direction!
Here is my SAS code
data control;
format Sex$6. Age;
input Sex$6. Age;
datalines;
Female 39.93673111
Male 39.93673111
;
run;
It was the format command that I needed to incorporate!
Have a wonderful day everyone!
Best
You should mark @ballardw as the correct solution, not your own answer.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: