<?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: question about array in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418847#M12822</link>
    <description>&lt;P&gt;Sorry, am trying to post again because it looked like it posted before as one long line of code...Again the goal is to do this array when another binary variable sex=1.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.workingfile; set final.finalfile; 
array DIAGNOSIS [50] DIAGNOSIS1-DIAGNOSIS50; 
do i=1 to 50; if DIAGNOSIS [i] &amp;gt; ' ' then do; 
NEW_DIAGNOSIS = DIAGNOSIS [i]; 
output; 
end;
end;
keep NEW_DIAGNOSIS;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Dec 2017 16:14:25 GMT</pubDate>
    <dc:creator>lmyers2</dc:creator>
    <dc:date>2017-12-06T16:14:25Z</dc:date>
    <item>
      <title>question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418777#M12813</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4 full edition. I'm wondering if you can use a where statement within an array.&amp;nbsp; I'm looking for a certain diagnosis within an array but only where sex=female. Could someone post a sample code conditioning on a binary predictor?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much!!!&lt;/P&gt;&lt;P&gt;Laura&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 13:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418777#M12813</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-06T13:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418780#M12815</link>
      <description>&lt;P&gt;Could you post some example test data describing what you mean?&amp;nbsp; Its impossible for us to guess what your working with.&amp;nbsp; If its a where clause rather than just code in a datastep, maybe doing something like:&lt;/P&gt;
&lt;PRE&gt;where index(catx(',',of arr:),"female")&amp;gt;0;&lt;/PRE&gt;
&lt;P&gt;So join all the values in the array together and then search for a substring of that.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 13:18:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418780#M12815</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-06T13:18:19Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418785#M12818</link>
      <description>&lt;P&gt;There are many statements that can be used with an array, but&amp;nbsp;a WHERE statement is not possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The WHERE statement has to examine data values within the incoming SAS data set, before those values get read into memory.&amp;nbsp; Any arrays that get defined within the DATA step don't even exist at that point.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;mentioned, if you give a more explicit example of what you are trying to accomplish, there may be some other way to get there.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 13:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418785#M12818</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-06T13:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418845#M12821</link>
      <description>&lt;P&gt;I agree, thanks for being willing to look at my code. I want the below array to run only when another binary variable is sex=1. I'm not sure if I can put a where statement in the do statement. When I tried, it failed so there must be another option but I can't find it on the SAS arrays document. Here it is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.workingfile; set final.finalfile; &lt;BR /&gt;array DIAGNOSIS [50] DIAGNOSIS1-DIAGNOSIS50; &lt;BR /&gt;do i=1 to 50;&lt;BR /&gt; if DIAGNOSIS [i] &amp;gt; ' ' then do;&lt;BR /&gt; NEW_DIAGNOSIS = DIAGNOSIS [i];&lt;BR /&gt; output;&lt;BR /&gt; end;&lt;BR /&gt;end;&lt;BR /&gt;keep NEW_DIAGNOSIS;&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418845#M12821</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-06T16:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418847#M12822</link>
      <description>&lt;P&gt;Sorry, am trying to post again because it looked like it posted before as one long line of code...Again the goal is to do this array when another binary variable sex=1.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.workingfile; set final.finalfile; 
array DIAGNOSIS [50] DIAGNOSIS1-DIAGNOSIS50; 
do i=1 to 50; if DIAGNOSIS [i] &amp;gt; ' ' then do; 
NEW_DIAGNOSIS = DIAGNOSIS [i]; 
output; 
end;
end;
keep NEW_DIAGNOSIS;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418847#M12822</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-06T16:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418849#M12823</link>
      <description>&lt;P&gt;It looks like your problem falls under the general "convert wide to skinny" file problem. Have you considered using PROC TRANSPOSE, which might remove the need to create a data step and to use arrays?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418849#M12823</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-12-06T16:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418852#M12824</link>
      <description>Yes, but for all other analysis except this, it's easier to have it in the wide format and use arrays so really I just need to figure this out once.&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:23:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418852#M12824</guid>
      <dc:creator>lmyers2</dc:creator>
      <dc:date>2017-12-06T16:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418854#M12825</link>
      <description>&lt;P&gt;To do what you describe requires a small change.&amp;nbsp; Right now you have:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead, you would need:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if sex=1 then do i=1 to 50;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because your logic contains an OUTPUT statement, nothing would ever get output for other values of sex.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418854#M12825</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-12-06T16:27:50Z</dc:date>
    </item>
    <item>
      <title>Re: question about array</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418856#M12826</link>
      <description>&lt;P&gt;Two options, one is a WHERE statement the second is a condition on your loop.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.workingfile; 
set final.finalfile; 

where sex='Female';


array DIAGNOSIS [50] DIAGNOSIS1-DIAGNOSIS50; 
do i=1 to 50;
    if  not missing(DIAGNOSIS [i]) then do; 
              NEW_DIAGNOSIS = DIAGNOSIS [i]; 
             output; 
    end;
end;

keep NEW_DIAGNOSIS;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Second:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.workingfile; 
set final.finalfile; 

where sex='Female';


array DIAGNOSIS [50] DIAGNOSIS1-DIAGNOSIS50; 
if sex='Female' then do i=1 to 50;
    if  not missing(DIAGNOSIS [i]) then do; 
              NEW_DIAGNOSIS = DIAGNOSIS [i]; 
             output; 
    end;
end;

keep NEW_DIAGNOSIS;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Dec 2017 16:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/question-about-array/m-p/418856#M12826</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-12-06T16:30:35Z</dc:date>
    </item>
  </channel>
</rss>

