BookmarkSubscribeRSS Feed
Kalai2008
Pyrite | Level 9

Hi All,

 

Need a help in this program.Little complicated. I have 5 dates (Byear1,byear2...-5), I am trying to get a new calculated column (youngest) where I need only the age of the least birthyear (2017-1958). Some birthyear variables are blank.

How to identify the least year from the 5 dates? 

 

proc sql;
create table test.age
as select  (2017-(birtyear1)) as Age1,

                 (2017-(byear2)) as Age2,

                 (2017-(byear3)) as Age3,

                 (2017-(byear4)) as Age4,

                  (2017-(byear5)) as Age5,

 

from..

 

Output should be like this!

Byear1  Byear2   Byear3  Byear4   Byear5    Age1   Age2  CalculatedCol(youngest)   

1955       1958         0          0             0             62                                59                                

 1962      1965        0          1964        0             55                                52                                  

1979      1978        0            0           1962         38                                38                                   

2 REPLIES 2
art297
Opal | Level 21

You will get more (or maybe at least some) responses if you provide example have and want datasets in the form of data steps we can run. Your examples use different variable names and one can't really see what you are trying to do.

 

Art, CEO, AnalystFinder.com

 

Reeza
Super User

MIN (of birthyear1-birthyear5) will provide the lowest value, ignoring missing values.

 

I would recommend you check what the standard is in your industry. 

Apparently demographics uses Age as of June1st for particular years, so if you're merging it with other sources that's a good indicator. 

When I did cancer research we had a different definition, so it can be industry/topic specific.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1023 views
  • 1 like
  • 3 in conversation