<?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: Help with sub setting output data sets in SAS/IML Software and Matrix Computations</title>
    <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/434353#M3984</link>
    <description>&lt;P&gt;Suppose I would like to set values of s to 1 where conditions are met, and leave them as 0 otherwise , and keep all the original observations from test. I tried this, but only was getting 1 value of s =0?&lt;/P&gt;</description>
    <pubDate>Mon, 05 Feb 2018 19:35:33 GMT</pubDate>
    <dc:creator>Vovik</dc:creator>
    <dc:date>2018-02-05T19:35:33Z</dc:date>
    <item>
      <title>Help with sub setting output data sets</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433789#M3981</link>
      <description>&lt;P&gt;Novis, trying to learn IML.&amp;nbsp; In the program below, I am trying to pick the LBN values which satisfies low - high range, create output dataset&amp;nbsp;test1&amp;nbsp; as subset of test which satisfy this condition in most efficient way (without listing all of the variables).&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc iml ;&lt;BR /&gt;use test;&lt;/P&gt;&lt;P&gt;read all var _NUM_ into x[c=NumVar];&lt;BR /&gt;close test;&lt;/P&gt;&lt;P&gt;r_x=nrow(x);&lt;BR /&gt;c_x=ncol(x);&lt;/P&gt;&lt;P&gt;/* Lab date variable d */&lt;BR /&gt;lbn = x[, 'd'];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*Upper Lower limits for week 100 boundaries*/&lt;BR /&gt;low = x[, 'const'] + 2;&lt;BR /&gt;high = x[, 'const'] + 15;&lt;/P&gt;&lt;P&gt;outc = x[,'s'];&lt;BR /&gt;/* outc = j(nrow(s), 1); */&lt;BR /&gt;idx = loc (lbn &amp;lt;= high &amp;amp; lbn &amp;gt;= low );&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;y=j(nrow());&lt;BR /&gt;if ncol (idx)&amp;gt; 0 then y[idx]=x;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;print x , y;&lt;BR /&gt;print satisfy "Criteria Met";&lt;BR /&gt;print (lbn[idx])[label='lab date'] , (low[idx]) [label='lowb'],&lt;BR /&gt;(high[idx]) [label='highb'], [label='test'];&lt;/P&gt;&lt;P&gt;create TEST1 from y ;&lt;BR /&gt;append from y;&lt;BR /&gt;close test1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 14:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433789#M3981</guid>
      <dc:creator>Vovik</dc:creator>
      <dc:date>2018-02-03T14:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Help with sub setting output data sets</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433790#M3982</link>
      <description>&lt;P&gt;Original test data:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test (drop=v);&lt;/P&gt;&lt;P&gt;p=1; d=2; z=3; const=11; s=0;&lt;BR /&gt;output;&lt;BR /&gt;&lt;BR /&gt;do v=1 to 15 by 1;&lt;BR /&gt;const=11;&lt;BR /&gt;p+3; d+5; z+7;&lt;BR /&gt;output;&lt;BR /&gt;&lt;BR /&gt;end;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 14:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433790#M3982</guid>
      <dc:creator>Vovik</dc:creator>
      <dc:date>2018-02-03T14:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: Help with sub setting output data sets</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433814#M3983</link>
      <description>&lt;P&gt;You have read all the variables into X. So use the LOC function to find the rows that satisfy the condition, then use the index to subset the rows of X:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;idx = loc (lbn &amp;lt;= high &amp;amp; lbn &amp;gt;= low );
y = x[idx,];   /* subset rows, include all columns */
create TEST1 from y[c=NumVar];
append from y;
close test1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you leave the column index blank (as above), it means "use all columns." For more information about subscripting matrices, see &lt;A href="https://blogs.sas.com/content/iml/2015/11/25/extract-elements-matrix.html" target="_self"&gt;"Extracting elements from matrix."&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 03 Feb 2018 16:50:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/433814#M3983</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-02-03T16:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Help with sub setting output data sets</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/434353#M3984</link>
      <description>&lt;P&gt;Suppose I would like to set values of s to 1 where conditions are met, and leave them as 0 otherwise , and keep all the original observations from test. I tried this, but only was getting 1 value of s =0?&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2018 19:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/434353#M3984</guid>
      <dc:creator>Vovik</dc:creator>
      <dc:date>2018-02-05T19:35:33Z</dc:date>
    </item>
    <item>
      <title>Re: Help with sub setting output data sets</title>
      <link>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/434374#M3985</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;z = j(nrow(x), 1, 0);  /* vector with all rows set to 0 */
z[idx] = 1;   /* change these rows to 1 */
x[,'s'] = z;   /* if you want to overwrite original data */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 05 Feb 2018 20:36:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-IML-Software-and-Matrix/Help-with-sub-setting-output-data-sets/m-p/434374#M3985</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-02-05T20:36:09Z</dc:date>
    </item>
  </channel>
</rss>

