<?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: Picking values from an array of variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893639#M353038</link>
    <description>&lt;P&gt;Now show what you expect the output to look like. I am not sure how many variables you actually expect to add. Is it one per increase/decrease (means maximum of 4 variables for increase and 4 for possible decreases) or&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Sep 2023 20:33:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2023-09-11T20:33:36Z</dc:date>
    <item>
      <title>Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893636#M353036</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;Please, I need help writing the codes to pick out values from an array of variables. So, the variables thirty_pct1-thirty_pct15 are variables showing if the patient had a 30% decrease in lab values from baseline, so 1 if 'yes' and 0 if 'no'; lab_date1-lab_date5 are the corresponding dates when the lab tests were done and&amp;nbsp;pct_chg1-pct_chg5 is the percent change from baseline. I want to create columns showing the first increase and next decrease with the corresponding lab_dates and pct_chg. The patient with ID 223 has two decreases and increases so there will be two columns for date of decrease and two for dates of increase.&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.CLASS(label='Student Data');
 input ID$3. thirty_pct1 thirty_pct2 thirty_pct3 thirty_pct4 thirty_pct5 lab_date1 lab_date2 lab_date3 lab_date4 lab_date5 pct_chg1 pct_chg2 pct_chg3 pct_chg4 pct_chg5;
 datalines;
222 0 1 1 0 1 2JAN2022 1FEB2022 4MAR2022 5APR2022 6MAY2022 -24 -31 -35 -19 -32
223 . 1 0 1 0 . 1FEB2022 4MAR2022 5APR2022 6MAY2022 . -31 -28 -33 -25
224 0 . 1 0 0 2JAN2022 . 4MAR2022 5APR2022 6MAY2022 -24 . -35 -19 -32
 ;run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893636#M353036</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2023-09-11T20:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893639#M353038</link>
      <description>&lt;P&gt;Now show what you expect the output to look like. I am not sure how many variables you actually expect to add. Is it one per increase/decrease (means maximum of 4 variables for increase and 4 for possible decreases) or&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:33:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893639#M353038</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-11T20:33:36Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893643#M353040</link>
      <description>&lt;P&gt;Thank you for your response. I expect the output to look like this:&lt;/P&gt;
&lt;P&gt;ID lab_date_of_decrease1&amp;nbsp; lab_date_of_decrease2&amp;nbsp; lab_date _of_increase1 labdate _of_increase2 percent_chg1&amp;nbsp; percent_chg2. The percentage would be for the decrease if there was a decrease or the last increase if there was no decrease.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 20:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893643#M353040</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2023-09-11T20:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893653#M353042</link>
      <description>&lt;P&gt;What if there are more than 2 increases or decreases? Since what I understand of your data is that the values are against a not-shown value at a some other date it seems like you might possibly have more than 2 possible&lt;/P&gt;</description>
      <pubDate>Mon, 11 Sep 2023 21:34:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893653#M353042</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-11T21:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893656#M353043</link>
      <description>There could be more than 2 or 3 increases and respective decreases the data. The real data has observation with more than 3 increases with respective decreases.&lt;BR /&gt;</description>
      <pubDate>Mon, 11 Sep 2023 22:05:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893656#M353043</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2023-09-11T22:05:21Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893674#M353046</link>
      <description>&lt;P&gt;If you want the FIRST how can there be more than one?&lt;/P&gt;
&lt;P&gt;Why is your data structured like this?&amp;nbsp; Why not just make a more normal dataset?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input ID :$3. thirty_pct1-thirty_pct5 (lab_date1-lab_date5) (:date.) pct_chg1-pct_chg5;
  format lab_date1-lab_date5 date9.;
datalines;
222 0 1 1 0 1 2JAN2022 1FEB2022 4MAR2022 5APR2022 6MAY2022 -24 -31 -35 -19 -32
223 . 1 0 1 0 . 1FEB2022 4MAR2022 5APR2022 6MAY2022 . -31 -28 -33 -25
224 0 . 1 0 0 2JAN2022 . 4MAR2022 5APR2022 6MAY2022 -24 . -35 -19 -32
;

data tall ;
  set have;
  array c thirty_pct1-thirty_pct5;
  array d lab_date1-lab_date5;
  array p pct_chg1-pct_chg5;
  do index=1 to dim(d);
    p30 = c[index];
    lab_date = d[index];
    pct_chg = p[index];
    output;
  end;
  format lab_date date9.;
  drop thirty_pct1-thirty_pct5 lab_date1-lab_date5 pct_chg1-pct_chg5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you have data like this instead:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1694476140249.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/87788iC54676595D3A0EA1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1694476140249.png" alt="Tom_0-1694476140249.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Now which of those individual records are the ones you want to keep for your new dataset?&lt;/P&gt;
&lt;P&gt;Is it something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set tall;
  where abs(pct_chg) &amp;gt; 30 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Sep 2023 23:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893674#M353046</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-11T23:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: Picking values from an array of variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893783#M353082</link>
      <description>&lt;P&gt;Thank you for your response, Tom. The record I would like to keep are highlighted in yellow. The pattern should be 101010 or 101 or 10 or 1010. It must begin with 1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UcheOkoro_0-1694526369552.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/87812i5A3F3A3CF0B1D952/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UcheOkoro_0-1694526369552.png" alt="UcheOkoro_0-1694526369552.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 13:47:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Picking-values-from-an-array-of-variables/m-p/893783#M353082</guid>
      <dc:creator>UcheOkoro</dc:creator>
      <dc:date>2023-09-12T13:47:54Z</dc:date>
    </item>
  </channel>
</rss>

