<?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: How do I repeat a data step for all variables in a dataset with the same suffix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315582#M68867</link>
    <description>&lt;P&gt;Thanks so much for your response! That is super helpful. I am running into one problem. I have many blank observations in these variables and this array is turning anyone blank into a 3. I tried using if &amp;amp;rounded_score ne . in a few different places, both before the array and in the array, but I can't quite get the proper syntax to make it function.&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;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2016 16:05:23 GMT</pubDate>
    <dc:creator>NCiaccia</dc:creator>
    <dc:date>2016-11-30T16:05:23Z</dc:date>
    <item>
      <title>How do I repeat a data step for all variables in a dataset with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/314386#M68459</link>
      <description>&lt;P&gt;In my dataset, I have many variables that end with the suffix _RND. For each observation in these variables, if the value is less than 0, I would like it to be 0 and if the value is greater than 3, I would like it to be 3. I've gotten so far as to be able to identify all of the variables in the dataset that end with the suffix and stored it in a list called rounded_scores (using the code below in SAS 9.4), but I dont know how to invoke this list and have the procedure repeated on each of these variables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc contents data=Henry out=contents(keep=name) noprint ;&lt;BR /&gt;Run;&lt;/P&gt;&lt;P&gt;proc sql noprint ;&lt;BR /&gt;select name into :rounded_scores separated by ' '&lt;BR /&gt;from contents&lt;BR /&gt;where upcase(name) like '%^_RND' escape '^'&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help you can give!&lt;/P&gt;</description>
      <pubDate>Sat, 26 Nov 2016 00:32:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/314386#M68459</guid>
      <dc:creator>NCiaccia</dc:creator>
      <dc:date>2016-11-26T00:32:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I repeat a data step for all variables in a dataset with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/314417#M68472</link>
      <description>&lt;P&gt;You have done most of the work. All that is missing is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set Henry;
array v{*} &amp;amp;rounded_scores;
do i = 1 to dim(v);
	v{i} = max(0, min(3, v{i}));
	end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Nov 2016 04:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/314417#M68472</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-26T04:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I repeat a data step for all variables in a dataset with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315582#M68867</link>
      <description>&lt;P&gt;Thanks so much for your response! That is super helpful. I am running into one problem. I have many blank observations in these variables and this array is turning anyone blank into a 3. I tried using if &amp;amp;rounded_score ne . in a few different places, both before the array and in the array, but I can't quite get the proper syntax to make it function.&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;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 16:05:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315582#M68867</guid>
      <dc:creator>NCiaccia</dc:creator>
      <dc:date>2016-11-30T16:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I repeat a data step for all variables in a dataset with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315611#M68877</link>
      <description>&lt;P&gt;To keep missing values as missing, all you need is:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set Henry;
array v{*} &amp;amp;rounded_scores;
do i = 1 to dim(v);
	if not missing(v{i}) then v{i} = max(0, min(3, v{i}));
	end;
drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Nov 2016 17:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315611#M68877</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-11-30T17:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I repeat a data step for all variables in a dataset with the same suffix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315617#M68879</link>
      <description>&lt;P&gt;Thank you! I also realized after I posted that I should be using v{i}. Whoops.&amp;nbsp;I found that this would also work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; Henry;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; v{*} &amp;amp;rounded_scores;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; i = &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; dim(v);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; v{i} ne &lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;then&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;v{i} = max(&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;, min(&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;3&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;, v{i}));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; i;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2016 17:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-repeat-a-data-step-for-all-variables-in-a-dataset-with/m-p/315617#M68879</guid>
      <dc:creator>NCiaccia</dc:creator>
      <dc:date>2016-11-30T17:41:55Z</dc:date>
    </item>
  </channel>
</rss>

