0
votes

I have a data which is in one column which has a mix of all data types, formats.

text, numeric and also date. I have to transpose the coloumn to rows. When I import the data in to sas 9.3 the dates are turning into a number (char format) and after transpose when I try to convert using the input function it is not giving the correct date. The observation I am getting is like 41172 in the date column. How do I convert it?

1
You're going to have to provide examples of what you've got and what you're doing. Off the top of my head numbers like that sound like Excel is the data source, and it's not properly coming into SAS (excel uses numbers like that as dates, 1/1/1900 not 1/1/1960), but you're not even providing that detail.Joe
Is this effectively the same as your previous question stackoverflow.com/questions/24762835/… ?Joe
41172 is the way Excel stores 20september2012Dirk Horsten

1 Answers

0
votes

Think you're confusing data types and formats. The two types are character and numeric.

Dates are all numeric, and are stored as a SASDATE which is the offset from 01 JAN 1960, with each day representing 1.

To have each SASDate be displayed, you must format that variable as a date (eg. date7, ddmmyy etc). That means you first need to use the input function to go from text to numeric (SASDate) then the put function to format it as you want it.

If you're using the input function, you just need to add one of those formats and a put function:

newvar=put(input(var,8.),date7.);

Or you could leave it as just the input() and use this:

format var date7.;

In your data step.