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


If I had a dataset that contained a Diabetes_Date and a Hypertension_date like the following:

ID      Diabetes_date      Hypertension_date

111     4/5/05                         7/10/06

222     3/4/14                         9/6/10

I need a new variable date that would list the date at which they had both Diabetes and Hypertension.  So for the above example it would be 7/10/06 for 111 and the 222 ID would be 3/4/14.  I know I could do a few if statements to accomplish this, but wondering if there are other easy methods.

Thanks so much!

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

Wouldn't it just be max(diabetes_date,hypertension_date)?  I think the max function propagates null values.

View solution in original post

2 REPLIES 2
DBailey
Lapis Lazuli | Level 10

Wouldn't it just be max(diabetes_date,hypertension_date)?  I think the max function propagates null values.

RichardinOz
Quartz | Level 8

No, I do not think max() propagates nulls unless all the parameters are null.  In fact I use max(value, 0) to set missing values to zero.  You need the N() function as well to count the number of non null values.

If n(Diabetes_date, hypertension_date) = 2

          then combined Date = max(diabetes_date,hypertension_date) ;

Richard

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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