I have a dataset with a variable with a date ISO and I need to compare it with another date to calculation duration.
| ID | ISOdt |
| -------- | -------- |
| US12 | 2012-05-01T14:34-05:00|
| US13 | 2022-04-22T15:00-05:00|
your text
isodt = 字符 256
I need to convert to a sas datetime to assign to a new variable and to calculate duration between 2 dates (which are also
ISO 日期格式)。`
`data test (keep=newdate stdat tmdat);
set extest;
format stdat $20. tmdat $10. newdate datetime13.;
stdat= ex_dt;
tmdat=ex_tm;
newdate=(stdat * 24 * 60 * 60) + tmdat;
newdate=input(compress(stdat)||':'||compress(tmdat), datetime13.);
run;`
your text
或
`数据测试(keep=newdate stdat tmdat);
设置扩展;
格式 stdat $20。 tmdat 10 美元。新日期 datetime13.;
stdat=输入(扫描(ex_dt,1,“T”),??yymmddn8。);
tmdat=输入(扫描(ex_dt,2,"T"),??time5.);
newdate=input(compress(stdat)||':'||compress(tmdat),datetime13.);
跑;``
your text
有关数字转换为字符的消息...但是变量为空。
I need an output like this:2012-05-01:14:34 or 01MAY2012 14:34 but i have to also use this date to c
计算两个日期之间的持续时间。
谢谢,`