09-25-2016 04:52 PM - edited 09-25-2016 05:03 PM
YYYY MM DD Company
2015 01 01 Comp1
2015 02 01 Comp2
2014 03 01 Comp3.....
Its an excel file with 10000 data sets.
What code will transform the given data into desired output?
09-25-2016 05:44 PM
Do you already know how to get your Excel files into a SAS data set, or is that part of the question?
Do you want your new fields as numeric or character?
09-25-2016 05:48 PM - edited 09-25-2016 05:49 PM
I know to get excel into sas. I want to know the codes in SAS that can give me the desired output.
I want a character as well as numeric conversion codes.
09-25-2016 07:04 PM
Whats the type (numeric/character) and format of the variable?
You can look at the YEAR/MONTH/DAY function in SAS if your variable is numeric with a date format.
PS. Why do you want to convert this? You can use all sorts of aggregation levels if you keep it as a SAS date.
09-25-2016 07:22 PM
Then use the YEAR/MONTH/DAY function to extract the relevant components.
See the relevant documentation under Date & Time Category:
09-25-2016 10:12 PM
Well, I'm going to go out on a limb, and assume that the number within DATE is actually the 8-digit number that appears in your example (and not a SAS date). In that case:
length yyyy_c $ 4 mm_c dd_c $ 2;
date_c = put(date, 8.);
yyyy_c = date_c;
mm_c = substr(date_c, 5, 2);
dd_c = substr(date_c, 7, 2);
yyyy_n = input(yyyy_c, 4.);
mm_n = input(mm_c, 2.);
dd_n = input(dd_c, 2.);
If I'm wrong, and you actually have a SAS date stored within DATE, then use the suggestion about date functions.