<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Infile - problems converting time variable to SAS format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Infile-problems-converting-time-variable-to-SAS-format/m-p/29592#M5594</link>
    <description>Hi!&lt;BR /&gt;
&lt;BR /&gt;
I am trying to read an infile (semicolon separated file) with a time variable in the format hh:mm and I am only able to read it as a char variable.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to tell SAS in the infile reading that this is a time variable and convert it to SAS format directly?&lt;BR /&gt;
&lt;BR /&gt;
I tried to convert it after the variable list:&lt;BR /&gt;
&lt;BR /&gt;
SASdate=input(VARNAME,hhmm.);&lt;BR /&gt;
&lt;BR /&gt;
but it didn't work (as it is a char variable, I guess...).&lt;BR /&gt;
&lt;BR /&gt;
Thankful for any help on this basic question! (Sorry for asking, I have tried to look it up on the online help but couldn't find anything helpful.)&lt;BR /&gt;
/Helen</description>
    <pubDate>Tue, 08 Jul 2008 14:36:16 GMT</pubDate>
    <dc:creator>HelenJ</dc:creator>
    <dc:date>2008-07-08T14:36:16Z</dc:date>
    <item>
      <title>Infile - problems converting time variable to SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-problems-converting-time-variable-to-SAS-format/m-p/29592#M5594</link>
      <description>Hi!&lt;BR /&gt;
&lt;BR /&gt;
I am trying to read an infile (semicolon separated file) with a time variable in the format hh:mm and I am only able to read it as a char variable.&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to tell SAS in the infile reading that this is a time variable and convert it to SAS format directly?&lt;BR /&gt;
&lt;BR /&gt;
I tried to convert it after the variable list:&lt;BR /&gt;
&lt;BR /&gt;
SASdate=input(VARNAME,hhmm.);&lt;BR /&gt;
&lt;BR /&gt;
but it didn't work (as it is a char variable, I guess...).&lt;BR /&gt;
&lt;BR /&gt;
Thankful for any help on this basic question! (Sorry for asking, I have tried to look it up on the online help but couldn't find anything helpful.)&lt;BR /&gt;
/Helen</description>
      <pubDate>Tue, 08 Jul 2008 14:36:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-problems-converting-time-variable-to-SAS-format/m-p/29592#M5594</guid>
      <dc:creator>HelenJ</dc:creator>
      <dc:date>2008-07-08T14:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: Infile - problems converting time variable to SAS format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Infile-problems-converting-time-variable-to-SAS-format/m-p/29593#M5595</link>
      <description>Hi:&lt;BR /&gt;
  Try an "informat" -- a format to use when you read in the data -- on the INPUT statement (assuming you have an INPUT statement):&lt;BR /&gt;
[pre]&lt;BR /&gt;
** make some data;&lt;BR /&gt;
data testdate;&lt;BR /&gt;
  infile datalines dlm=',';&lt;BR /&gt;
  input var1 $ datevar : mmddyy10. &lt;BR /&gt;
        timevar : time5.&lt;BR /&gt;
        var2 var3;&lt;BR /&gt;
  format datevar date7. timevar time5.;&lt;BR /&gt;
datalines;&lt;BR /&gt;
aaa,11/15/1950,19:35,101,202&lt;BR /&gt;
bbb,11/15/1950,09:42,111,222&lt;BR /&gt;
ccc,10/17/1991,14:45,333,444&lt;BR /&gt;
ddd,11/29/1984,10:36,555,666&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                        &lt;BR /&gt;
 options nodate nonumber nocenter;&lt;BR /&gt;
ods listing;&lt;BR /&gt;
** print data WITH assigned formats;&lt;BR /&gt;
proc print data=testdate;&lt;BR /&gt;
  title '1) use assigned formats';&lt;BR /&gt;
run;&lt;BR /&gt;
                                      &lt;BR /&gt;
** print data WITH diff formats to show values;&lt;BR /&gt;
proc print data=testdate;&lt;BR /&gt;
  title '2) with diff formats display values';&lt;BR /&gt;
  format datevar mmddyy10. timevar time8.;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
If you already have a dataset, then the TIME. informat should work for your conversion:&lt;BR /&gt;
[pre]&lt;BR /&gt;
  timevar = input(chartime,time5.);&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 08 Jul 2008 15:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Infile-problems-converting-time-variable-to-SAS-format/m-p/29593#M5595</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2008-07-08T15:01:43Z</dc:date>
    </item>
  </channel>
</rss>

