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

data sasprg.data1;
infile datalines delimiter=" ";
input Bday $ Date date11. Timer stimer5. Country $ Gender $;
format Date date11. Timer time5.;
datalines;
29SEP2018 29-Aug-19 10:36 ARGENTINA Male;

run;

Output:

Obs Bday Date Timer Country Gender1

29SEP20129-AUG-20190:00ARGENTINMale

 

Please advise to get an value of timer variable in output table as 10:36

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why are you reading 11 character for the date value when it only has 9?

Try using LIST mode input instead of FORMATTED mode.  Also make sure you include at least one line of data.  The datalines stop on the last line BEFORE the semi-colon.  Also no need to include an extra RUN statement after the end of your data step.

data sasprg.data1;
  infile datalines ;
  input Bday :$9. Date :date. Timer :stimer. Country :$30. Gender :$7.;
  format Date date11. Timer time5.;
datalines;
29SEP2018 29-Aug-19 10:36 ARGENTINA Male
;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Why are you reading 11 character for the date value when it only has 9?

Try using LIST mode input instead of FORMATTED mode.  Also make sure you include at least one line of data.  The datalines stop on the last line BEFORE the semi-colon.  Also no need to include an extra RUN statement after the end of your data step.

data sasprg.data1;
  infile datalines ;
  input Bday :$9. Date :date. Timer :stimer. Country :$30. Gender :$7.;
  format Date date11. Timer time5.;
datalines;
29SEP2018 29-Aug-19 10:36 ARGENTINA Male
;
Ksharp
Super User
data data1;
infile datalines delimiter=" ";
input Bday : $20. Date : date11. Timer : time. Country $ Gender $;
format Date date9. Timer time5.;
datalines;
29SEP2018 29-Aug-19 10:36 ARGENTINA Male
;
run;

sas-innovate-white.png

🚨 Early Bird Rate Extended!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.

 

Lock in the best rate now before the price increases on April 1.

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 548 views
  • 1 like
  • 3 in conversation