Hi,
I have a column Named "Date" which is in format YYYY-MM and they are stored in character value .
I want to convert them into numeric format so that I can create a new variable called "Newdate" to store SAS date value.
Thanks in Advance.
You have to make a decision which day to use for an incomplete date.
If that should be the first of the month, do
newdate = input(date !! '-01',yymmdd10.);
format newdate yymmddd10.;
Hi KurtBremser,
Thank you very much for your response!!! it worked perfectly I really appreciate your help
Again, thanks so much!!
Best,
Gowtham
Dates are stored as number of days since a given time. So to convert your text into a number SAS needs to be able to calculate how many days since that date there are, and without day value it cannot do this, hence it cannot convert to numeric date. The same thing happens with times, so seconds since. Give it a default number, then you can always apply a format - i.e. change the display of the underlying data - to YYYY-MM.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.