<?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 change multiple time variables to character time in array in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/change-multiple-time-variables-to-character-time-in-array/m-p/517690#M140021</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with multiple timepoints in each observation (eg.&amp;nbsp; lbtim1 lbtim2 lbtim3...).&amp;nbsp; They are all in time5. numeric format.&lt;/P&gt;
&lt;P&gt;How can I change all of these to character format (TOD5.)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of the time variables have the same prefix 'lbtim'&amp;nbsp; with the timepoint.&amp;nbsp; Here is what I started with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data prsupp;&lt;BR /&gt;set db.lbi;&lt;BR /&gt;&lt;BR /&gt;array timn (*) lbitim:;&lt;BR /&gt;array timc (*) lbtimc:;&lt;BR /&gt;do i= 1 to dim (timn);&lt;BR /&gt;if ~missing (timn(i)) then timc(i)=put(timn(i),tod5.);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it's something with the new character variables I'm trying to create.&amp;nbsp; Or can I just overwrite the numeric variables to character somehow?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help is appreciated!&lt;/P&gt;</description>
    <pubDate>Fri, 30 Nov 2018 22:14:10 GMT</pubDate>
    <dc:creator>jenim514</dc:creator>
    <dc:date>2018-11-30T22:14:10Z</dc:date>
    <item>
      <title>change multiple time variables to character time in array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-multiple-time-variables-to-character-time-in-array/m-p/517690#M140021</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a dataset with multiple timepoints in each observation (eg.&amp;nbsp; lbtim1 lbtim2 lbtim3...).&amp;nbsp; They are all in time5. numeric format.&lt;/P&gt;
&lt;P&gt;How can I change all of these to character format (TOD5.)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All of the time variables have the same prefix 'lbtim'&amp;nbsp; with the timepoint.&amp;nbsp; Here is what I started with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data prsupp;&lt;BR /&gt;set db.lbi;&lt;BR /&gt;&lt;BR /&gt;array timn (*) lbitim:;&lt;BR /&gt;array timc (*) lbtimc:;&lt;BR /&gt;do i= 1 to dim (timn);&lt;BR /&gt;if ~missing (timn(i)) then timc(i)=put(timn(i),tod5.);&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess it's something with the new character variables I'm trying to create.&amp;nbsp; Or can I just overwrite the numeric variables to character somehow?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Help is appreciated!&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 22:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-multiple-time-variables-to-character-time-in-array/m-p/517690#M140021</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2018-11-30T22:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: change multiple time variables to character time in array</title>
      <link>https://communities.sas.com/t5/SAS-Programming/change-multiple-time-variables-to-character-time-in-array/m-p/517695#M140023</link>
      <description>&lt;P&gt;Are you sure you need a character variable? Often using the desired format at the appropriate time is sufficient.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is that you created a numeric variable with your array statement and likely incorrectly if the variables are supposed to be new.&lt;/P&gt;
&lt;P&gt;Do the lbtimc: variables already exist? If not the following doesn't work because it will create an array of 0 elements that would be numeric. I expect that your log showed something like:&lt;/P&gt;
&lt;PRE&gt;WARNING: Defining an array with zero elements.
&lt;/PRE&gt;
&lt;P&gt;after the line with the line array timc (*) lbtimc:;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS cannot read your mind to know that you want another variable to match a list of existing variables.&lt;/P&gt;
&lt;P&gt;Use&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="SAS Monospace" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; lbtimc (&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;5&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt;) $&lt;/FONT&gt;&lt;FONT color="#008080" face="SAS Monospace" size="2"&gt;6&lt;/FONT&gt;&lt;FONT face="SAS Monospace" size="2"&gt; ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="SAS Monospace" size="2"&gt;to create 5 &lt;STRONG&gt;new&lt;/STRONG&gt; variables lbtimc1-5 of length 6 characters. Use the number that matches your data.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;If you leave out the 6 the variables will default to 8 characters&lt;/P&gt;</description>
      <pubDate>Fri, 30 Nov 2018 22:29:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/change-multiple-time-variables-to-character-time-in-array/m-p/517695#M140023</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-30T22:29:22Z</dc:date>
    </item>
  </channel>
</rss>

