<?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 writing quasi-complex conditional processing (how to) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584795#M166637</link>
    <description>&lt;P&gt;Both versions, run separately, run without errors but fail to function as intended. I could certainly write out a longer version but what's wrong here?&amp;nbsp;I run through the array and reset the value of the variable if the current value equals the test value but the test value depends on the current element in the array. What's happening is that any variable in the array that has a value of 3 is reset to .p.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array vrra{31} Drr1-Drr31;&lt;/P&gt;&lt;P&gt;*******&amp;nbsp; Version 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;do i=1 to 31;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;******** Version 2;&lt;/P&gt;&lt;P&gt;do i=1 to 31;&lt;BR /&gt;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (13-18, 20, 22-26) and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the follow up question. spss is my first stats program and in there i could do this.&lt;/P&gt;&lt;P&gt;do repeat x=Drr1 to Drr5/y=3 3 6 7 3.&lt;/P&gt;&lt;P&gt;+&amp;nbsp; &amp;nbsp;if (x eq y) x=9. /* let 9 stand for .p.&lt;/P&gt;&lt;P&gt;end repeat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe sas has something like that, or not, i don't know. But what about this? Can something like this be done?&lt;/P&gt;&lt;P&gt;array vrra{5} Drr1-Drr5;&lt;/P&gt;&lt;P&gt;array temp{5} 3 3 6 7 3;&amp;nbsp; /* so temp is a temporay array that disappears along with its contents after run execution */&lt;/P&gt;&lt;P&gt;do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;if (vrra{i} eq temp{i}) vrra{i}=.p;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gene Maguin&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2019 21:22:14 GMT</pubDate>
    <dc:creator>emaguin</dc:creator>
    <dc:date>2019-08-28T21:22:14Z</dc:date>
    <item>
      <title>writing quasi-complex conditional processing (how to)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584795#M166637</link>
      <description>&lt;P&gt;Both versions, run separately, run without errors but fail to function as intended. I could certainly write out a longer version but what's wrong here?&amp;nbsp;I run through the array and reset the value of the variable if the current value equals the test value but the test value depends on the current element in the array. What's happening is that any variable in the array that has a value of 3 is reset to .p.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;array vrra{31} Drr1-Drr31;&lt;/P&gt;&lt;P&gt;*******&amp;nbsp; Version 1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;do i=1 to 31;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;******** Version 2;&lt;/P&gt;&lt;P&gt;do i=1 to 31;&lt;BR /&gt;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (13-18, 20, 22-26) and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here the follow up question. spss is my first stats program and in there i could do this.&lt;/P&gt;&lt;P&gt;do repeat x=Drr1 to Drr5/y=3 3 6 7 3.&lt;/P&gt;&lt;P&gt;+&amp;nbsp; &amp;nbsp;if (x eq y) x=9. /* let 9 stand for .p.&lt;/P&gt;&lt;P&gt;end repeat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe sas has something like that, or not, i don't know. But what about this? Can something like this be done?&lt;/P&gt;&lt;P&gt;array vrra{5} Drr1-Drr5;&lt;/P&gt;&lt;P&gt;array temp{5} 3 3 6 7 3;&amp;nbsp; /* so temp is a temporay array that disappears along with its contents after run execution */&lt;/P&gt;&lt;P&gt;do i=1 to 5;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;if (vrra{i} eq temp{i}) vrra{i}=.p;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Gene Maguin&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 21:22:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584795#M166637</guid>
      <dc:creator>emaguin</dc:creator>
      <dc:date>2019-08-28T21:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: writing quasi-complex conditional processing (how to)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584798#M166640</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Both versions, run separately, run without errors but fail to function as intended.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;I may have missed it in your post but it's not clear what you 'intend'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you show some sample input data and what you expect as output?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/273054"&gt;@emaguin&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Both versions, run separately, run without errors but fail to function as intended. I could certainly write out a longer version but what's wrong here?&amp;nbsp;I run through the array and reset the value of the variable if the current value equals the test value but the test value depends on the current element in the array. What's happening is that any variable in the array that has a value of 3 is reset to .p.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array vrra{31} Drr1-Drr31;&lt;/P&gt;
&lt;P&gt;*******&amp;nbsp; Version 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;do i=1 to 31;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;&amp;nbsp; &amp;nbsp;else if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;******** Version 2;&lt;/P&gt;
&lt;P&gt;do i=1 to 31;&lt;BR /&gt;if (i le 11 and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (13-18, 20, 22-26) and vrra{i} eq 3) then vrra{i}=.p;&lt;BR /&gt;if (i in (12, 19, 21, 27) and vrra{i} eq 6) then vrra{i}=.p;&lt;BR /&gt;if (i in (28, 29, 30, 31) and vrra{i} eq 7) then vrra{i}=.p;&lt;BR /&gt;end;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here the follow up question. spss is my first stats program and in there i could do this.&lt;/P&gt;
&lt;P&gt;do repeat x=Drr1 to Drr5/y=3 3 6 7 3.&lt;/P&gt;
&lt;P&gt;+&amp;nbsp; &amp;nbsp;if (x eq y) x=9. /* let 9 stand for .p.&lt;/P&gt;
&lt;P&gt;end repeat.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe sas has something like that, or not, i don't know. But what about this? Can something like this be done?&lt;/P&gt;
&lt;P&gt;array vrra{5} Drr1-Drr5;&lt;/P&gt;
&lt;P&gt;array temp{5} 3 3 6 7 3;&amp;nbsp; /* so temp is a temporay array that disappears along with its contents after run execution */&lt;/P&gt;
&lt;P&gt;do i=1 to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if (vrra{i} eq temp{i}) vrra{i}=.p;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gene Maguin&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 21:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584798#M166640</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-08-28T21:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: writing quasi-complex conditional processing (how to)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584806#M166645</link>
      <description>&lt;P&gt;There is a syntax error in your code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;13-18, 20, 22-26&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;should be&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;13:18, 20, 22:26&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 22:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584806#M166645</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-08-28T22:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: writing quasi-complex conditional processing (how to)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584817#M166656</link>
      <description>&lt;P&gt;An example of &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;comment about the syntax of the IN&amp;nbsp; list you are using in the version 2:&lt;/P&gt;
&lt;PRE&gt;data example;
   do i= 1 to 10;
      inlist= ( i in (2-5,7, 8-10));
      rightlist = ( i in (2:5,7, 8:10));
      put i= inlist= rightlist=;
   end;
run;&lt;/PRE&gt;
&lt;P&gt;Inlist and Rightlist will have a value of 1 when I is found in the list. Note that only the first of values in the hyphenated are matched for Inlist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With a smaller set of variables but the same type of code as your version 1 a cannot duplicate getting "all values of 3" set to .P.&lt;/P&gt;
&lt;P&gt;So either the code you ran is different than shown or perhaps you have other code assigning values of P, or copying from one of the affected variables.&lt;/P&gt;
&lt;P&gt;Since you did not show 1) an entire data step, 2) the log entry from running the code and 3) provided no test data it is hard to determine what may have happened to set "all values of 3".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;array temp{5} 3 3 6 7 3;&amp;nbsp; /* so temp is a temporay array that disappears along with its contents after run execution */&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A temporary array of that sort would look like&lt;/P&gt;
&lt;PRE&gt;array t{5} _temporary_ (3,3,6,7,3);&lt;/PRE&gt;
&lt;P&gt;Caution: temporary arrays are not reset at each iteration of the data step. So if change values inside the array they will be the new values for the next record(s).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the values I am seeing I would hazard guess that something like certain question responses are being set where the same "not really useful for analysis value" like "Don't know" "Refused" or similar is set to .P.&lt;/P&gt;
&lt;P&gt;I tend to that with custom informats when reading data most of the time. So none of this scattered array indexing is needed.&lt;/P&gt;
&lt;P&gt;Or create three separate arrays for the purpose of recoding.&lt;/P&gt;
&lt;P&gt;Variables can be assigned to multiple arrays if needed. So if your vrra is doing something else other than recoding then recode in separate arrays for groups of variables prior to the other stuff.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Aug 2019 00:10:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/writing-quasi-complex-conditional-processing-how-to/m-p/584817#M166656</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-29T00:10:45Z</dc:date>
    </item>
  </channel>
</rss>

