BookmarkSubscribeRSS Feed
Daniela_P
Obsidian | Level 7

Dear experts,

 

I'm trying to read from a txt file a variable written in this way: hh:mm

using infile procedure. Below I exemplify what I'm doing:

 

 

filename READ "C:\READ.txt";
filename FILE_A "C:\FILE_A.txt";
data FILE_A (compress=yes );
infile FILE_A lrecl=24  missover;
INPUT %include READ;;
run;

 

where file NEW is this:

1IST2006611:24
1IST2006610:31
1IST20066 9:15
1IST2006618:22

 

and READ is this:

A        1-1
B  $    2-9
TIMEVAR $ 10-14

 

In the imported FILE_A the variable TIMEVAR is as aspected, in char format.

 

How can I use the same procedure specifying that TIMEVAR has to be read in time5. format?

 

Thanks to all in advance,

Daniela

1 REPLY 1
FreelanceReinh
Jade | Level 19

Use formatted input with the TIME5. informat for this variable, i.e., replace "TIMEVAR $ 10-14" by "TIMEVAR time5.". You can then apply the TIME5. format to TIMEVAR for display purposes.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 882 views
  • 0 likes
  • 2 in conversation