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

I was able to create a new variable called 'Age' which = number of years of age the person was at the time of symptoms onset using this code:

data Age;
set HospitalDays;
Age = (dateSymptoms - DOB);
format Age years.
run;

It worked perfectly! however, even when I used format Age years. the numbers are displayed as days from DOB to symptoms vs years.  

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Formats won't get the job done in this case. They can display dates as year, but your variable Age is not a date.

 

In an earlier thread, you said your lab asked you to use a specific function to do this. What function was it, and did you try that? If not, please try it.

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Formats won't get the job done in this case. They can display dates as year, but your variable Age is not a date.

 

In an earlier thread, you said your lab asked you to use a specific function to do this. What function was it, and did you try that? If not, please try it.

--
Paige Miller
saza
Quartz | Level 8
data Age;
set HospitalDays;
Age = yrdif(DOB, dateSymptoms);
run;

Hi Paige! I just needed to tweak my proc transpose to make the rest of my code work. the code above worked to help me some for the years,

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

What is ANOVA?

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.

Discussion stats
  • 2 replies
  • 766 views
  • 1 like
  • 2 in conversation