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

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!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

8 REPLIES 8
Reeza
Super User
Can you show a proc freq output for sex on both data sets?
Jake3
Calcite | Level 5

Sure. Here is one for the "Control" dataset 

Control.png

and here is the one for the "Survival" dataset 

 

Main.png

 

Reeza
Super User

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;
Jake3
Calcite | Level 5
Hi Reeza

Really appreciate you taking the time to help me. I figured out what the issue was. When I do that I get the same results
ballardw
Super User

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.

Jake3
Calcite | Level 5
Thank you Ballardw! It was indeed a format issue
Jake3
Calcite | Level 5

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 

Reeza
Super User

You should mark @ballardw  as the correct solution, not your own answer.

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
How to Concatenate Values

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.

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