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,

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!
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
  • 600 views
  • 1 like
  • 2 in conversation