<?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 How to Loop through a datastep reusing a variable with multiple categories in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-to-Loop-through-a-datastep-reusing-a-variable-with-multiple/m-p/809805#M33794</link>
    <description>&lt;P&gt;I know there must be a way to loop through a datastep using 1 variable with multiple categories but I can't figure it out how. If someone could help me out that would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to repeat the data step below using all of the different categories within the variable "Priority"&lt;/P&gt;
&lt;P&gt;The control should stay priority = 2&lt;/P&gt;
&lt;P&gt;But I want the case persons to loop through the other categories = 1, 3, 4, 5 so that I get 4 different Odds Ratios&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;VALUE CC&lt;BR /&gt;1 = "CONTROL"&lt;BR /&gt;2 = "CASE"&lt;BR /&gt;3 = "EXPOSURE+"&lt;BR /&gt;4 = "EXPOSURE-";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%LET EXPOSURE = NRT ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA want;&lt;BR /&gt;SET have;&lt;BR /&gt;&lt;BR /&gt;/* CONTROL PERSON = WHITE FORMER SMOKER*/&lt;BR /&gt;IF PRIORITY = 2 AND SMOKE=4 THEN CCGROUP = 1;&lt;BR /&gt;/* CASE PERSON = INDV PRIORITY GROUP + CURRENT SMOKER*/&lt;BR /&gt;IF PRIORITY = 5 AND SMOKE=5 THEN CCGROUP = 2;&lt;BR /&gt;&lt;BR /&gt;/* EXPOSURE (+) YES USED NRT*/&lt;BR /&gt;IF &amp;amp;EXPOSURE = 1 THEN CCGROUP = 3;&lt;BR /&gt;/* EXPOSURE (-) DID NOT USE NRT */&lt;BR /&gt;IF &amp;amp;EXPOSURE = 2 THEN CCGROUP= 4; &lt;BR /&gt;&lt;BR /&gt;FORMAT CCGROUP CC. ;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FREQ DATA= COMPARISONGROUPS ORDER=FREQ;&lt;BR /&gt;TABLES CCGROUP*EXP / OR;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2022 04:59:22 GMT</pubDate>
    <dc:creator>Deanna_Payne</dc:creator>
    <dc:date>2022-04-26T04:59:22Z</dc:date>
    <item>
      <title>How to Loop through a datastep reusing a variable with multiple categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Loop-through-a-datastep-reusing-a-variable-with-multiple/m-p/809805#M33794</link>
      <description>&lt;P&gt;I know there must be a way to loop through a datastep using 1 variable with multiple categories but I can't figure it out how. If someone could help me out that would be great.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to repeat the data step below using all of the different categories within the variable "Priority"&lt;/P&gt;
&lt;P&gt;The control should stay priority = 2&lt;/P&gt;
&lt;P&gt;But I want the case persons to loop through the other categories = 1, 3, 4, 5 so that I get 4 different Odds Ratios&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format;&lt;/P&gt;
&lt;P&gt;VALUE CC&lt;BR /&gt;1 = "CONTROL"&lt;BR /&gt;2 = "CASE"&lt;BR /&gt;3 = "EXPOSURE+"&lt;BR /&gt;4 = "EXPOSURE-";&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;%LET EXPOSURE = NRT ;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;DATA want;&lt;BR /&gt;SET have;&lt;BR /&gt;&lt;BR /&gt;/* CONTROL PERSON = WHITE FORMER SMOKER*/&lt;BR /&gt;IF PRIORITY = 2 AND SMOKE=4 THEN CCGROUP = 1;&lt;BR /&gt;/* CASE PERSON = INDV PRIORITY GROUP + CURRENT SMOKER*/&lt;BR /&gt;IF PRIORITY = 5 AND SMOKE=5 THEN CCGROUP = 2;&lt;BR /&gt;&lt;BR /&gt;/* EXPOSURE (+) YES USED NRT*/&lt;BR /&gt;IF &amp;amp;EXPOSURE = 1 THEN CCGROUP = 3;&lt;BR /&gt;/* EXPOSURE (-) DID NOT USE NRT */&lt;BR /&gt;IF &amp;amp;EXPOSURE = 2 THEN CCGROUP= 4; &lt;BR /&gt;&lt;BR /&gt;FORMAT CCGROUP CC. ;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC FREQ DATA= COMPARISONGROUPS ORDER=FREQ;&lt;BR /&gt;TABLES CCGROUP*EXP / OR;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 04:59:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Loop-through-a-datastep-reusing-a-variable-with-multiple/m-p/809805#M33794</guid>
      <dc:creator>Deanna_Payne</dc:creator>
      <dc:date>2022-04-26T04:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Loop through a datastep reusing a variable with multiple categories</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-to-Loop-through-a-datastep-reusing-a-variable-with-multiple/m-p/809826#M33795</link>
      <description>&lt;P&gt;Your code steps have no relation to each other; in one you create dataset want from dataset have, in the other you use dataset comparisongroups.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please show us the code you really run to get a single result, and present the source data for this code in usable form (in a data step with datalines, so we can quickly and unambiguously recreate your example data).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 08:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-to-Loop-through-a-datastep-reusing-a-variable-with-multiple/m-p/809826#M33795</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-04-26T08:21:39Z</dc:date>
    </item>
  </channel>
</rss>

