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

Good evening,

 

The code below is producing missing values for all values of the Rec_Date variable.  This is running on 9.2  in UNIX.

Sample data appears as follows:

 

"First ID","Second ID","Name","Rec Date"
"121","012","Martin","2015/12/22 00:00:00"
"1956","056","Breida","2015/11/22 00:00:00"

 

Can someone help me understand what I'm missing?

 

Thanks!

data control;

length
	first_ID		$20
	second_ID	$20
	name	        $50;
infile control dsd missover firstobs=2;
input
	first_ID		$
	second_ID	$
	name	         $
	Rec_Date	         anydtdtm.;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Maybe the problem is that csv file is created under Windows, while you are importing it via Unix . They have different terminator character of line .

 

 

data control;
infile '/folders/myfolders/temp.txt' dsd truncover firstobs=2 termstr=crlf;
input
	first_ID	: $20.
	second_ID	: $20.
	name	    : $50.
	Rec_Date	: anydtdtm.;
run;

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

Could you try to change the informat used for reading the datetime like below , i used the colon (:) and the informat to anydtdtm20. .

 

 

data control;

length
	first_ID		$20
	second_ID	$20
	name	        $50;
infile control dsd missover firstobs=2;
input
	first_ID		$
	second_ID	$
	name	         $
	Rec_Date	 :        anydtdtm20.;
run;

 

Thanks,
Jag
Ksharp
Super User

Maybe the problem is that csv file is created under Windows, while you are importing it via Unix . They have different terminator character of line .

 

 

data control;
infile '/folders/myfolders/temp.txt' dsd truncover firstobs=2 termstr=crlf;
input
	first_ID	: $20.
	second_ID	: $20.
	name	    : $50.
	Rec_Date	: anydtdtm.;
run;
old_man_hank
Fluorite | Level 6

Thanks Ksharp!  That is exactly what the issue was.  Apparently UNIX uses a "LF" to terminate the line while files created in Windows have the "CRLF".  Once I specified that the terminator characater is "CRLF", the file read the date without issue.

 

Text file common problems

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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