l******o 发帖数: 162 | 1 three variables (all numeric)
year month day
need to convert to yyyymmdd SAS format so that I can calculate the days
between this yyyymmdd with another yyyymmdd.
can anybody help me with this?
Many thanks. |
g*******y 发帖数: 380 | 2 you can use mdy function.
try search online, for instance: google: "sas, mdy (function)".
For an example: the following code is online:
DATA dates;
INPUT month 1-2 year 4-7 day 9-10;
bday=MDY(month,day,year);
CARDS;
7 1948 11
1 1960 1
10 1970 15
12 1971 10
;
RUN;
btw: SAS date is numeric, if you just need diffenrence between two dates?
you don't have to format it as yyyymmdd or else. |
d********h 发帖数: 2048 | 3 why convert?
difference=(year1-year2)*365+(month1-month2)*12+(day1-day2); |
l******o 发帖数: 162 | 4 many thanks. mdy works well. |
l******o 发帖数: 162 | 5 year, month, day are THREE variables while another is only yyyymmdd. so I
have to convert.
bdy works well.
【在 d********h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : why convert? : difference=(year1-year2)*365+(month1-month2)*12+(day1-day2);
|
l******o 发帖数: 162 | 6 I only have 1.70 cash in my a/c and just couldn't give you any money. Sorry.
【在 g*******y 的大作中提到】![](/moin_static193/solenoid/img/up.png) : you can use mdy function. : try search online, for instance: google: "sas, mdy (function)". : For an example: the following code is online: : DATA dates; : INPUT month 1-2 year 4-7 day 9-10; : bday=MDY(month,day,year); : CARDS; : 7 1948 11 : 1 1960 1 : 10 1970 15
|
g*******y 发帖数: 380 | 7 客气,这个也要包子的话,我在版上得到的帮助足够我破产了.
Sorry.
【在 l******o 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I only have 1.70 cash in my a/c and just couldn't give you any money. Sorry.
|