<?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 array to impute new variable value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/array-to-impute-new-variable-value/m-p/627791#M185400</link>
    <description>&lt;P&gt;I'm new to using arrays. Can anyone help me fix this code? What I'm trying to do is shown in the data step below. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gfr0;&lt;BR /&gt;set gfr0;&lt;BR /&gt;array date[*] date1-date680;&lt;BR /&gt;do i=1 to dim(date);&lt;BR /&gt;if date[i]=closest then do;&lt;BR /&gt;egfr0= /* here is my problem /* ;&lt;BR /&gt;output;&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my "slow" code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gfr0;&lt;BR /&gt;set gfr0;&lt;BR /&gt;if date1=closest then egfr0=reply1;&lt;BR /&gt;if date2=closest then egfr0=reply2;&lt;BR /&gt;if date3=closest then egfr0=reply3;&lt;BR /&gt;if date4=closest then egfr0=reply4;&lt;BR /&gt;if date5=closest then egfr0=reply5;&lt;BR /&gt;if date6=closest then egfr0=reply6;&lt;BR /&gt;if date7=closest then egfr0=reply7;&lt;BR /&gt;if date8=closest then egfr0=reply8;&lt;BR /&gt;if date9=closest then egfr0=reply9;&lt;BR /&gt;if date10=closest then egfr0=reply10;&lt;BR /&gt;if date11=closest then egfr0=reply11;&lt;BR /&gt;if date12=closest then egfr0=reply12;&lt;BR /&gt;if date13=closest then egfr0=reply13;&lt;BR /&gt;if date14=closest then egfr0=reply14;&lt;BR /&gt;if date15=closest then egfr0=reply15;&lt;BR /&gt;if date16=closest then egfr0=reply16;&lt;BR /&gt;if date17=closest then egfr0=reply17;&lt;BR /&gt;if date18=closest then egfr0=reply18;&lt;BR /&gt;if date19=closest then egfr0=reply19;&lt;BR /&gt;if date20=closest then egfr0=reply20;&lt;BR /&gt;if date21=closest then egfr0=reply21;&lt;BR /&gt;.....&lt;/P&gt;</description>
    <pubDate>Thu, 27 Feb 2020 07:17:12 GMT</pubDate>
    <dc:creator>greveam</dc:creator>
    <dc:date>2020-02-27T07:17:12Z</dc:date>
    <item>
      <title>array to impute new variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-impute-new-variable-value/m-p/627791#M185400</link>
      <description>&lt;P&gt;I'm new to using arrays. Can anyone help me fix this code? What I'm trying to do is shown in the data step below. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gfr0;&lt;BR /&gt;set gfr0;&lt;BR /&gt;array date[*] date1-date680;&lt;BR /&gt;do i=1 to dim(date);&lt;BR /&gt;if date[i]=closest then do;&lt;BR /&gt;egfr0= /* here is my problem /* ;&lt;BR /&gt;output;&lt;BR /&gt;leave;&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my "slow" code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data gfr0;&lt;BR /&gt;set gfr0;&lt;BR /&gt;if date1=closest then egfr0=reply1;&lt;BR /&gt;if date2=closest then egfr0=reply2;&lt;BR /&gt;if date3=closest then egfr0=reply3;&lt;BR /&gt;if date4=closest then egfr0=reply4;&lt;BR /&gt;if date5=closest then egfr0=reply5;&lt;BR /&gt;if date6=closest then egfr0=reply6;&lt;BR /&gt;if date7=closest then egfr0=reply7;&lt;BR /&gt;if date8=closest then egfr0=reply8;&lt;BR /&gt;if date9=closest then egfr0=reply9;&lt;BR /&gt;if date10=closest then egfr0=reply10;&lt;BR /&gt;if date11=closest then egfr0=reply11;&lt;BR /&gt;if date12=closest then egfr0=reply12;&lt;BR /&gt;if date13=closest then egfr0=reply13;&lt;BR /&gt;if date14=closest then egfr0=reply14;&lt;BR /&gt;if date15=closest then egfr0=reply15;&lt;BR /&gt;if date16=closest then egfr0=reply16;&lt;BR /&gt;if date17=closest then egfr0=reply17;&lt;BR /&gt;if date18=closest then egfr0=reply18;&lt;BR /&gt;if date19=closest then egfr0=reply19;&lt;BR /&gt;if date20=closest then egfr0=reply20;&lt;BR /&gt;if date21=closest then egfr0=reply21;&lt;BR /&gt;.....&lt;/P&gt;</description>
      <pubDate>Thu, 27 Feb 2020 07:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-impute-new-variable-value/m-p/627791#M185400</guid>
      <dc:creator>greveam</dc:creator>
      <dc:date>2020-02-27T07:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: array to impute new variable value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/array-to-impute-new-variable-value/m-p/627793#M185401</link>
      <description>&lt;P&gt;I can't see your data, but something like this may do&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data gfr0;
   set gfr0;
   array date[*]  date1-date680;
   array reply[*] reply1-reply680;
   do i=1 to dim(date);
      if date[i]=closest then do;
         egfr0=reply[i];
         output;
         leave;
      end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Feb 2020 07:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/array-to-impute-new-variable-value/m-p/627793#M185401</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-02-27T07:20:38Z</dc:date>
    </item>
  </channel>
</rss>

