<?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 Using a loop to perform a set of steps on each unique value for a given variable? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58943#M16574</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Normally to generate multiple datasets you will need to use some type of code generation tool.&amp;nbsp; Either SAS macro code or you can do it yourself with a data step and a %INC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename code temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by client_name ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.client_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; file code;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where = quote(trim(client_name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; put 'data split_' client_name ';'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; set have;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; where client_name=' where ';'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / 'run;'&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%inc code / source2 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Aug 2011 19:42:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2011-08-31T19:42:25Z</dc:date>
    <item>
      <title>Using a loop to perform a set of steps on each unique value for a given variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58942#M16573</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a field called CLIENT_NAME that has several different entries that can change depending on the dataset I'm feeding in.&amp;nbsp; Because there is room for variation, using a macro to define the CLIENT_NAME values I want to use won't work each time.&amp;nbsp; Is there a way to use a DO statement to create a loop that will go through every single unique value for a given variable?&amp;nbsp; For instance, if I have 26 Client Names in a given dataset, the DO statement would run through the associated block of code 26 times, ultimately producing 26 datasets.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 19:27:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58942#M16573</guid>
      <dc:creator>AvocadoRivalry</dc:creator>
      <dc:date>2011-08-31T19:27:07Z</dc:date>
    </item>
    <item>
      <title>Using a loop to perform a set of steps on each unique value for a given variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58943#M16574</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Normally to generate multiple datasets you will need to use some type of code generation tool.&amp;nbsp; Either SAS macro code or you can do it yourself with a data step and a %INC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filename code temp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by client_name ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if first.client_name;&lt;/P&gt;&lt;P&gt;&amp;nbsp; file code;&lt;/P&gt;&lt;P&gt;&amp;nbsp; where = quote(trim(client_name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; put 'data split_' client_name ';'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; set have;'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / '&amp;nbsp; where client_name=' where ';'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; / 'run;'&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%inc code / source2 ;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 19:42:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58943#M16574</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-08-31T19:42:25Z</dc:date>
    </item>
    <item>
      <title>Using a loop to perform a set of steps on each unique value for a given variable?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58944#M16575</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If the goal is to create separate datasets, and then deal with each separately, why not use a hash? e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE style="font-size: 1.2em; overflow-x: auto; overflow-y: auto;"&gt;&lt;P&gt;data _null_ ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; dcl hash hh&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;&lt;P&gt;&amp;nbsp; hh.definekey&amp;nbsp; ('k'&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ) ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; hh.definedata ('sex', 'name', 'age', 'height', 'weight') ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; hh.definedone () ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do until(mod(k,5)=0 or last);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; k+1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class end=last ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; hh.add();&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; hh.output(dataset: 'a'||strip(k));&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Aug 2011 19:57:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-a-loop-to-perform-a-set-of-steps-on-each-unique-value-for/m-p/58944#M16575</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-08-31T19:57:21Z</dc:date>
    </item>
  </channel>
</rss>

