BookmarkSubscribeRSS Feed
Bal23
Lapis Lazuli | Level 10

the original dataset has date variables are listed as 20051001, 20160705

would you please recommend how to convert them to sas date

 

FORMAT date date9.;
date= input(date, yymmdd10.);
7 REPLIES 7
Reeza
Super User

You can't change a variable type in place, you need to recreate a new variable.

 

FORMAT date_new date9.;
date_new= input(date, yymmdd10.);
Bal23
Lapis Lazuli | Level 10

sorry, my previous message was not clear

i did the same way as you said,

 

with a new variable

but the new varabile has all missing values

 

the date format is yyyymmdd, like 20160705, i do not know how to convert

Reeza
Super User

Was there an error or note in your log?

Bal23
Lapis Lazuli | Level 10

thanks.

there was no error

the problem disappeared when i ran my code again (eighter 8 or 10), so it might  the sas or my computer problem?

Reeza
Super User

Possibly. It's more likely you had some other issue and running from the beginning fixed it. 

This is especially true if your in the habit of naming your output the same at the dataset in your SET statement. 

 

Data want;
Set want;

...

Run;
Bal23
Lapis Lazuli | Level 10

thanks

sas-innovate-2024.png

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.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 7 replies
  • 3058 views
  • 3 likes
  • 3 in conversation