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
;
proc
print 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.0 | 46.7 | 10.6 |
. | 4.75 | 5.49 | 61.3 | 75 | 20.0 | 19.3 | 7.1 |
. | 4.95 | 5.79 | 65.5 | 62 | 20.0 | 19.8 | 7.6 |
. | 5.34 | 6.77 | . | 102 | 33.5 | 33.5 | 8.3 |
. | 5.44 | 6.16 | 86.6 | 100 | 32.0 | 31.8 | 8.7 |
. | 6.71 | 7.46 | 164.2 | 184 | 67.0 | 67.5 | 15.7 |
Thank you guys
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 ;
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
;
proc
print 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.0 46.7 10.6 . 4.75 5.49 61.3 75 20.0 19.3 7.1 . 4.95 5.79 65.5 62 20.0 19.8 7.6 . 5.34 6.77 . 102 33.5 33.5 8.3 . 5.44 6.16 86.6 100 32.0 31.8 8.7 . 6.71 7.46 164.2 184 67.0 67.5 15.7
Thank you guys
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 ;
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.