I am having an issue with formatting/ proc phreg, i'll attach my code below:
However, doing this gives me this error code:
ERROR: Variable SEX in WORK.COVS does not have the same format as in the input data
Can anyone please help me spot my mistake, I am completely lost, thankyou
Hi @rachelm22,
Does variable SEX in dataset work.sasp have values 1 for males and 2 for females (as in dataset covs)? If so, it should be sufficient to copy the FORMAT statement from your DATA step into the PROC PHREG step:
proc phreg data = WORK.sasp plots(overlay=group)=(survival); format SEX SEX.; class SEX; ...
Also, you may want to specify an output dataset name (with the OUT= option) in the BASELINE statement so that SAS doesn't create datasets with default names using the DATAn convention.
Can you please show us the LOG so we can see the code and the error in the sequence shown in the log. Seeing errors detached from the code is not really that helpful.
Please copy the log as text, not as a screen capture, and paste it into your reply by clicking on the </> icon and pasting it into the window that appears. Thanks!
289 proc phreg data = WORK.sasp plots(overlay=group)=(survival); 290 class SEX; 291 model TIMEE*CENSE(0)=SEX|AGE BMI|BMI KCAL; 292 baseline covariates=covs / rowid=BMI group=SEX; 293 run; ERROR: Variable SEX in WORK.COVS does not have the same format as in the input data. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.DATA8 may be incomplete. When this step was stopped there were 0 observations and 0 variables. NOTE: PROCEDURE PHREG used (Total process time): real time 0.03 seconds cpu time 0.06 seconds
proc format; value SEX 1 = "male" 2 = "female"; run; data covs; format SEX SEX.; input SEX BMI AGE KCAL; datalines; 1 25 49.5 1981.95 1 30 49.5 1981.95 1 40 49.5 1981.95 2 25 49.5 1981.95 2 30 49.5 1981.95 2 40 49.5 1981.95 ; run; PROC PRINT DATA= covs; run; Proc contents data=covs; run; proc phreg data = WORK.sasp plots(overlay=group)=(survival); class SEX; model TIMEE*CENSE(0)=SEX|AGE BMI|BMI KCAL; baseline covariates=covs / rowid=BMI group=SEX; run;
above is my code
Please supply an example for dataset SASP, similar to what you did for COVS.
Please post code by copy/pasting to a "code box". A code box is opened with the "little running man" button right next to the one marked in the picture:
Hi @rachelm22,
Does variable SEX in dataset work.sasp have values 1 for males and 2 for females (as in dataset covs)? If so, it should be sufficient to copy the FORMAT statement from your DATA step into the PROC PHREG step:
proc phreg data = WORK.sasp plots(overlay=group)=(survival); format SEX SEX.; class SEX; ...
Also, you may want to specify an output dataset name (with the OUT= option) in the BASELINE statement so that SAS doesn't create datasets with default names using the DATAn convention.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.