12-26-2016 09:18 PM
This morning when I was dealing with a data, I faced a probelm related to date transformation.
This data is store in Excel (.xls), and the variable "admission" in Excel looks like:
However, after I import this data into SAS by the following code, variable "admission" change to.
PROC IMPORT OUT= WORK.test
DATAFILE= "E:\HardDriveBackUp\BackUp\CL-Wu\AHF\AHF 2015 AHEA
My question is "how to convert this admission variable into YYMMDD or substract the year?"
I've tried some methods to convert it, but i failed.
Last, I show some informations to you that I think it is useful when converting this.
1.when this data imported in SAS, it's variable type "number" (know this from proc contents)
2.my code which fail to convert is as follows:
DATA test;SET WORK.AHF;
testdate = INPUT(PUT(admission,12.),YYMMDD8.);
FORMAT testdate YYMMDD8.;
12-26-2016 11:06 PM
SAS assumes 1 Jan 1960 is day 0. Excel assumes 1 Jan 1900 is day 1. You can therefore add or subtract 21 916 from the date depending on whether you are going from Excel to SAS or SAS to Excel. Be careful of negative numbers. SAS accepts the date as being before 1 Jan 1960, Excel does not recognise it.
You can refer this link:
Need further help from the community? Please ask a new question.