Hello-,
I have a date format below. I want to drop the last four digit ie 1950 and 1421 from the date and subtract 2/10/2017-2/9/2017
data AA;
input ADT_IN ADT_OUT;
2/9/2017 1950 | 2/10/2017 1421 |
2/8/2017 1750 | 2/10/2017 1240 |
2/7/2017 1143 | 2/9/2017 1250 |
2/8/2017 1256 | 2/11/2017 0042 |
2/8/2017 1357 | 2/9/2017 1339 |
2/8/2017 1236 | 2/10/2017 1809 |
2/8/2017 1236 | 2/10/2017 1809 |
;
How do I perform length of stay (LOS) using the above data. LOS= out-in above
works
data D_HPT;
set D_HPT;
los=input(scan(ADT_out,1," "),ddmmyy10.)-input(scan(ADT_IN,1," "),ddmmyy10.)/365;
run;
SCAN to separate components
INPUT to convert character to date
I do not understand.
data a;
date1="2/9/2017 1950";
date2="2/10/2017 1421";
diff=input(scan(date2,1," "),ddmmyy10.)-input(scan(date1,1," "),ddmmyy10.);
run;![sas.JPG sas.JPG](https://communities.sas.com/t5/image/serverpage/image-id/14153i083D23B1837EAC84/image-size/large?v=v2&px=999)
I did not work.
data D_HPT;
set D_HPT;
los=input(scan(ADT_out,1," "),ddmmyy10.)-input(scan(ADT_IN,1," "),ddmmyy10.);
run;
Post your example dataset (in a data step!), so we can see the content and attributes of your variables.
"It did not work" is about as helpful as "a bicycle tipped over in Beijing". So post the log of your code, and how the result (if there was one) differed from your expectations.
@desireatem wrote:
I did not work.
data D_HPT;
set D_HPT;
los=input(scan(ADT_out,1," "),ddmmyy10.)-input(scan(ADT_IN,1," "),ddmmyy10.);
run;
Thank you
works
data D_HPT;
set D_HPT;
los=input(scan(ADT_out,1," "),ddmmyy10.)-input(scan(ADT_IN,1," "),ddmmyy10.)/365;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: