09-04-2014 02:09 PM
I have data like below:
patid ageyears agemon visdate
001 7 10 2014-02-10
003 15 6 2014-01-15
NEEDED like below:
patid age visdate
001 P7Y10M 2014-02-10
003 P15Y6M 2014-01-15
Can Guru's help me with populating age as above
Thanks in advance
09-04-2014 03:06 PM
Another way that I know,
data want(keep=patid age visdate);
RETAIN patid age visdate;
09-05-2014 12:12 AM
ISO 8601 formats are available in v9 and are documented here:
But personally I find them rather fiddly and I think Hima's suggestions are good.
09-05-2014 01:47 AM
As everyone can work with his own calendar and clock there are many possibilities. But wanting to understand each other is needing an agreement that we use some standard.
For clock/time we have gmt hours/seconds being defined. For dates the iso-standards (8601) are becoming getting accepted. The metric system still being difficult for acceptance Metric system - Wikipedia, the free encyclopedia. We could have done for the French revolutions way French Republican Calendar - Wikipedia, the free encyclopedia. Little chance for those now. Date/time calculations are not that easy in a Georgian approach there is a 28-year period. Week-numbers are overlapping in the year-change.
The data/time convention with SAS as a number since the arbitrary point of zero 1 jan 1960 0:0:0 is a good way for calculations.
For date/time duration calculations intck: SAS(R) 9.3 Functions and CALL Routines: Reference
For advancing back and up in time intnx: SAS(R) 9.3 Functions and CALL Routines: Reference
For presenting something age in a structure PyyMdd use formats. In this case the string is varying between 4 and 6. (advice fix that on 6, usage of blanks or zeros)
Of course you can manipulate strings as you did with pencil and paper. At some moment you will find that getting very complicated when using computers.
Suppose you are needing to recalculate after some time, knowing the birthday or making a good guess of that. It is about data quality.