<?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 Re: assign the closet value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234204#M42812</link>
    <description>&lt;P&gt;Thank you for the reponse!!! for the sample data it is working fine. but on my real data i got this error. and in my example data i gave only 5 dy variable(dy1-dy5) but in my realy data it has more than 100. so icreate a macro variable and assing the value to array like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;array dy_all dy1&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;dy&amp;amp;obs.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed. - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 11 Nov 2015 14:58:12 GMT</pubDate>
    <dc:creator>sam369</dc:creator>
    <dc:date>2015-11-11T14:58:12Z</dc:date>
    <item>
      <title>assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234139#M42795</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have veritical data . I need to create a variable which is close to the value. I am createing a reqvar variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cond:&lt;/P&gt;
&lt;P&gt;reqvar is missing then dy1 is missing or ev&amp;lt;dy1 or ev-dy:(dy1 dy2 dy3 dy4 dy5)&amp;gt;80&lt;/P&gt;
&lt;P&gt;assing val: for whose time point is close to ev&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; have;&lt;/P&gt;
&lt;P&gt;input sub ev cnt dy1 dy2 dy3 dy4 dy5 val1 val2 val3 val4 val5;&lt;/P&gt;
&lt;P&gt;cards;&lt;/P&gt;
&lt;P&gt;100 255 5 25 55 78 90 110 .5 .9 1.5 6 8&lt;/P&gt;
&lt;P&gt;101 90&amp;nbsp;&amp;nbsp; 3 40 83 87 . . .6 .8 1.7 . .&lt;/P&gt;
&lt;P&gt;103 24&amp;nbsp;&amp;nbsp; 2 25 30 .&amp;nbsp;&amp;nbsp; . . .9 .9 . . .&lt;/P&gt;
&lt;P&gt;104 100 5 80 90 99 180 200 1.8 1.9 2 6 9&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; want;&lt;/P&gt;
&lt;P&gt;sub ev cnt reqvar&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;100&lt;/STRONG&gt; &lt;STRONG&gt;255&lt;/STRONG&gt; &lt;STRONG&gt;5&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (it is missing because ev -dy &amp;gt;80)&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;101&lt;/STRONG&gt; &lt;STRONG&gt;90&lt;/STRONG&gt; &lt;STRONG&gt;3&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;1.7&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (assigned closet day ev=90 &amp;amp; dy3 =87 then assign value val3=1.7)&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;103&lt;/STRONG&gt; &lt;STRONG&gt;24&lt;/STRONG&gt; &lt;STRONG&gt;2&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (it is missing because ev &amp;lt;dy1)&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;104&lt;/STRONG&gt; &lt;STRONG&gt;100&lt;/STRONG&gt; &lt;STRONG&gt;5&lt;/STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; assigned closet day ev=100 &amp;amp; dy3 =99, dy4 is 180 duration b/w ev-dy4 &amp;gt;80 so assign value&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; val3=2)&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Thanks&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sam&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2015 22:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234139#M42795</guid>
      <dc:creator>sam369</dc:creator>
      <dc:date>2015-11-10T22:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234149#M42800</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Give this a try. This can&amp;nbsp;be done in fewer data steps, but I kept it simple for illustrative purposes. Enjoy!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hbi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA have;
INPUT sub ev cnt dy1 dy2 dy3 dy4 dy5 val1 val2 val3 val4 val5;
cards;
100 255 5 25 55 78  90 110  .5  .9 1.5 6 8
101  90 3 40 83 87   .   .  .6  .8 1.7 . .
103  24 2 25 30  .   .   .  .9  .9   . . .
104 100 5 80 90 99 180 200 1.8 1.9   2 6 9
;
RUN;


/* fix up dataset; find minimums; filter out unwanted computed values */
DATA temp;
  SET have;
  ARRAY dy_all  dy1-dy5;
  ARRAY dy_diff diff1-diff5;
  ARRAY val_all val1-val5;

  i=0;
  DO OVER dy_all;
    i+1;
    IF (ev - dy_all &amp;gt; 80) THEN dy_diff[i] = .;
    ELSE IF (ev &amp;lt; dy_all) THEN dy_diff[i] = .;
    ELSE                       dy_diff[i] = ev - dy_all;
  END;

  min_diff = MIN(of dy_diff[*]);

  DO j=1 TO 5;
    IF (NMISS(min_diff, dy_diff[j]) = 0) THEN DO;
      IF min_diff = dy_diff[j] THEN target_var = j;
    END;
  END;

  IF NOT MISSING(target_var) THEN reqvar = val_all[target_var];
RUN;


DATA want;
  SET temp;
  DROP dy1       dy2         dy3    dy4    dy5    
       val1      val2        val3   val4   val5   
       diff1     diff2       diff3  diff4  diff5  
       min_diff  target_var  i      j;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 11 Nov 2015 02:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234149#M42800</guid>
      <dc:creator>hbi</dc:creator>
      <dc:date>2015-11-11T02:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234204#M42812</link>
      <description>&lt;P&gt;Thank you for the reponse!!! for the sample data it is working fine. but on my real data i got this error. and in my example data i gave only 5 dy variable(dy1-dy5) but in my realy data it has more than 100. so icreate a macro variable and assing the value to array like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;array dy_all dy1&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;dy&amp;amp;obs.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed. - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="position: absolute; top: -1999px; left: -1988px;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Nov 2015 14:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234204#M42812</guid>
      <dc:creator>sam369</dc:creator>
      <dc:date>2015-11-11T14:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234259#M42823</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;array dy_all dy1&lt;SPAN class="token operator"&gt;-&lt;/SPAN&gt;dy&amp;amp;obs.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="stcpDiv" style="left: -1988px; top: -1999px; position: absolute;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed. - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="left: -1988px; top: -1999px; position: absolute;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV id="stcpDiv" style="left: -1988px; top: -1999px; position: absolute;"&gt;ERROR: Mixing of implicit and explicit array subscripting is not allowed - See more at: &lt;A href="http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf" target="_blank"&gt;http://compgroups.net/comp.soft-sys.sas/array-index/133326#sthash.gy1yuUJi.dpuf&lt;/A&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your array statement doesn't have the number of elements. Does this work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array dy_all {&amp;amp;obs} dy1-dy&amp;amp;obs;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 18:57:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234259#M42823</guid>
      <dc:creator>slangan</dc:creator>
      <dc:date>2015-11-11T18:57:19Z</dc:date>
    </item>
    <item>
      <title>Re: assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234267#M42825</link>
      <description>&lt;P&gt;Hi ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried that one too. But no luck&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 19:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234267#M42825</guid>
      <dc:creator>sam369</dc:creator>
      <dc:date>2015-11-11T19:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: assign the closet value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234280#M42830</link>
      <description>&lt;P&gt;Your array definition is fine. &amp;nbsp;You do not need to tell SAS in two places how many elements are in your array. So these are all equivalent definitions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array dy_all dy1-dy100 ;
array dy_all (100) dy1-dy100;

%let n=100;
array dy_all dy1-dy&amp;amp;n ;
array dy_all (&amp;amp;n) dy1-dy&amp;amp;n ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN style="line-height: 20px;"&gt;The error message is talking about how the array is REFERENCED, not how it is defined. You can&amp;nbsp;&lt;/SPAN&gt;use the "implicit" array reference of the DO OVER statement if you always reference the array that way. Once you start using explicit references using an index value like DY_ALL(i) then you need to use it everywhere. &amp;nbsp;So you would need to replace:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do over dy_all ;
   dy_all = ....
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i=1 to dim(dy_all);
   dy_all(i)= ...
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2015 20:19:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/assign-the-closet-value/m-p/234280#M42830</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-11-11T20:19:06Z</dc:date>
    </item>
  </channel>
</rss>

