## Combine the (m-dd-yy) into one variable representing the date.

Solved
Occasional Contributor
Posts: 17

# Combine the (m-dd-yy) into one variable representing the date.

Hello, guys

I'm struggling in a date issue. I searched for informat date statement and did not find this type of format M-DD-YY.

here is my data

3-05-98,5.79,7.69,112.8,128,47,46.7,10.6
4-06-98,4.75,5.49,61.3,75,20,19.3,7.1
4-07-98,4.95,5.79,65.5,62,20,19.8,7.6
2-25-98,5.34,6.77,.,102,33.5,33.5,8.3

This my code

`data limes;infile "/folders/myshortcuts/SASUniversityEdition/module 3/limes.txt"firstobs=2 dsd ;input date fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt;procprint data = limes;`

Obs date fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt 1 2 3 4 5 6

 . 5.79 7.69 112.8 128 47 46.7 10.6 . 4.75 5.49 61.3 75 20 19.3 7.1 . 4.95 5.79 65.5 62 20 19.8 7.6 . 5.34 6.77 . 102 33.5 33.5 8.3 . 5.44 6.16 86.6 100 32 31.8 8.7 . 6.71 7.46 164.2 184 67 67.5 15.7

Thank you guys

Accepted Solutions
Solution
‎07-10-2017 08:54 AM
PROC Star
Posts: 508

## Re: Combine the (m-dd-yy) into one variable representing the date.

this worked for me

```data limes
;
infile datalines dsd ;
;
input
date:mmddyy10. fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt;
format date date9.;
datalines;
3-05-98,5.79,7.69,112.8,128,47,46.7,10.6
4-06-98,4.75,5.49,61.3,75,20,19.3,7.1
4-07-98,4.95,5.79,65.5,62,20,19.8,7.6
2-25-98,5.34,6.77,.,102,33.5,33.5,8.3
;```

All Replies
Super User
Posts: 23,662

## Re: Combine the (m-dd-yy) into one variable representing the date.

Try the informat of ANYDTDTE or MMDDYY10.  Either appeared to work fine for me.

Koke wrote:

Hello, guys

I'm struggling in a date issue. I searched for informat date statement and did not find this type of format M-DD-YY.

here is my data

3-05-98,5.79,7.69,112.8,128,47,46.7,10.6
4-06-98,4.75,5.49,61.3,75,20,19.3,7.1
4-07-98,4.95,5.79,65.5,62,20,19.8,7.6
2-25-98,5.34,6.77,.,102,33.5,33.5,8.3

This my code

`data limes;infile "/folders/myshortcuts/SASUniversityEdition/module 3/limes.txt"firstobs=2 dsd ;input date fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt;procprint data = limes;`

Obs date fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt 1 2 3 4 5 6

 . 5.79 7.69 112.8 128 47 46.7 10.6 . 4.75 5.49 61.3 75 20 19.3 7.1 . 4.95 5.79 65.5 62 20 19.8 7.6 . 5.34 6.77 . 102 33.5 33.5 8.3 . 5.44 6.16 86.6 100 32 31.8 8.7 . 6.71 7.46 164.2 184 67 67.5 15.7

Thank you guys

Solution
‎07-10-2017 08:54 AM
PROC Star
Posts: 508

## Re: Combine the (m-dd-yy) into one variable representing the date.

this worked for me

```data limes
;
infile datalines dsd ;
;
input
date:mmddyy10. fruitdia f_length fruit_Wt f_vol J_vol juice_wt peel_wt;
format date date9.;
datalines;
3-05-98,5.79,7.69,112.8,128,47,46.7,10.6
4-06-98,4.75,5.49,61.3,75,20,19.3,7.1
4-07-98,4.95,5.79,65.5,62,20,19.8,7.6
2-25-98,5.34,6.77,.,102,33.5,33.5,8.3
;```
Super User
Posts: 10,209

## Re: Combine the (m-dd-yy) into one variable representing the date.

[ Edited ]

The MMDDYY, DDMMYY and YYMMDD informats can all deal with single-digit days and months, so you don't need to look for a special format for dates written like that.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
☑ This topic is solved.