BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TB2
Fluorite | Level 6 TB2
Fluorite | Level 6

I am trying to convert a date variable into an 8 digit numeric field (YYYYMMDD).

 

Currently it is in MMDDYY10. format and informat.

 

Example:

What is occuring:

Current_DATE = 08/01/2015 

 

What I want:

Current_Date = 20150801

 

Any suggestions?

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

First question: why?

Storing as a date will give you all the flexibility of using formats and functions adopted for dates.

If you persist, nest input() and put() functions.

Data never sleeps

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

First question: why?

Storing as a date will give you all the flexibility of using formats and functions adopted for dates.

If you persist, nest input() and put() functions.

Data never sleeps
TB2
Fluorite | Level 6 TB2
Fluorite | Level 6

Thanks. 

 

I am setting up datasets to run through a SAS program that someone else wrote. The instructions say to use numeric values for dates.

 

Here is the code I used for reference:

 

DATA ENROLLMENT_UPDATE;
  SET ENROLLMENT;
  DOBNEW=input(PUT(DOB, yymmddn8.),8.);
RUN;
Astounding
PROC Star

DOB is (probably) already numeric.  So when you say that the program expects numeric values, you need to know which numeric values it expects.  It may be that you don't need to change a thing.

Reeza
Super User

You can Keep it as a SAS date but display it that way  

 

format date yymmddn8.;

 

 

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
  • 4 replies
  • 701 views
  • 3 likes
  • 4 in conversation