<?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: Long if-then in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129256#M35233</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use multiple characters to map to one using proc format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;invalue $ groups&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Alfred', 'Alice', 'William' = 'Group1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Barbara', 'Carol', 'Thomas' = 'Group2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'John', 'Joyce', 'Judy' = 'Group3'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other='Group4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group=input(name, $groups.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have the mappings in a dataset you can use CNTLIN to read them in as well, you don't have to type them all out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify character ranges as follows, but you'll want to make sure you fully understand how that works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;invalue $ groups&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A'-'A~' = 'Group1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B' - 'B~' = 'Group2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'John', 'Joyce', 'Judy' = 'Group3'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other='Group4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group=input(name, $groups.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Oct 2013 19:13:15 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2013-10-30T19:13:15Z</dc:date>
    <item>
      <title>Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129253#M35230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am attaching some code, I have a very large amount of if-then statements to flag different statuses.&amp;nbsp; I'm only copy and pasting so it should be easy enough, I'm just curious if there is something I can do to neaten up the code and make it more efficient.&amp;nbsp; There will be thousands of rows if I keep up like this.&amp;nbsp; I have 20 flags to label 3 tables and a very large amount of 'if's.&amp;nbsp; If you can look at the attachment and suggest a different way to write this I would appreciate it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 18:26:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129253#M35230</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T18:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129254#M35231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Proc Format. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Especially if you'll be reusing the groupings. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm a fan of the paper: Proc Format: Not just anther pretty face...you can easily find it online.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 18:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129254#M35231</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-30T18:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129255#M35232</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there any way to do something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value $ hcc19fmt ('&lt;/P&gt;&lt;P&gt;249.00','&lt;/P&gt;&lt;P&gt;249.01','&lt;/P&gt;&lt;P&gt;250.00','&lt;/P&gt;&lt;P&gt;250.01','&lt;/P&gt;&lt;P&gt;250.02','&lt;/P&gt;&lt;P&gt;250.03','&lt;/P&gt;&lt;P&gt;V58.67'&lt;/P&gt;&lt;P&gt;) = '19';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;I see ranges being used when it's a number that I'm listing for the format but not a list of characters.&amp;nbsp; Do I have to put ='19' after every row in the proc format?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 19:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129255#M35232</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T19:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129256#M35233</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use multiple characters to map to one using proc format:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;invalue $ groups&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Alfred', 'Alice', 'William' = 'Group1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'Barbara', 'Carol', 'Thomas' = 'Group2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'John', 'Joyce', 'Judy' = 'Group3'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other='Group4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group=input(name, $groups.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have the mappings in a dataset you can use CNTLIN to read them in as well, you don't have to type them all out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can specify character ranges as follows, but you'll want to make sure you fully understand how that works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;invalue $ groups&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'A'-'A~' = 'Group1'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'B' - 'B~' = 'Group2'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'John', 'Joyce', 'Judy' = 'Group3'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other='Group4';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; group=input(name, $groups.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 19:13:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129256#M35233</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-30T19:13:15Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129257#M35234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's awesome, great help.&amp;nbsp; One last question, here's what I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; invalue $ testfmt&lt;/P&gt;&lt;P&gt;'249.00','249.01'='19';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;HCC_CODE = input(dx_1_cd,$testfmt.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I only want HCC_CODE to generate IF the value equals the format.&amp;nbsp; I hope that makes sense.&amp;nbsp; In this example I only want HCC_CODE to populate if the value is going to be '19', and be blank otherwise.&lt;/P&gt;&lt;P&gt;Is that possible?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 19:28:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129257#M35234</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T19:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129258#M35235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; invalue $ testfmt&lt;/P&gt;&lt;P&gt;'249.00','249.01'='19'&lt;/P&gt;&lt;P&gt;other=''&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 19:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129258#M35235</guid>
      <dc:creator>MumSquared</dc:creator>
      <dc:date>2013-10-30T19:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129259#M35236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can try the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if indexw(input(dx_1_cd,$testfmt.),'19') ne 0 then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HCC_CODE = input(dx_1_cd,$testfmt.);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129259#M35236</guid>
      <dc:creator>Marina</dc:creator>
      <dc:date>2013-10-30T20:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129260#M35237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have another problem,&amp;nbsp; I wanted to do this on 4 variables, that seems to present another issue, there is another table that I want to do this on 18 variables.&amp;nbsp; I'm not sure this will be the right path to take in this situation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your thoughts?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129260#M35237</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T20:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129261#M35238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Perfect path to take if you're applying it to multiple variables because you can just&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;new_var=input(old_var, $fmt_name.) on each one instead of recoding all of them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:28:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129261#M35238</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-30T20:28:49Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129262#M35239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is this what you mean?&amp;nbsp; I've attached what I have that seems to get the desired results but I'm thinking it's a remedial way to get to the desired result:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:32:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129262#M35239</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T20:32:33Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129263#M35240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The previous attachment had typos, this is correct.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 20:37:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129263#M35240</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2013-10-30T20:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129264#M35241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think your first parts correct, I think the second part is a different question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd suggest reposting that as a new question.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My guess is you could just use the whichc function instead or an array but you need to expand it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129264#M35241</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2013-10-30T21:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Long if-then</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129265#M35242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;length hcc_code $4.;&lt;BR /&gt;set test;&lt;/P&gt;&lt;P&gt;hcc_code="";&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;* you will need to list all 18 variables;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array dx_cd (18) dx_1_cd dx_2_cd ... dx_18_cd;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;do i=1 to 18;&lt;/P&gt;&lt;P&gt;if hcc_code = "" then do;&lt;/P&gt;&lt;P&gt;if indexw(input(dx_cd(i),$testfmt.),'80') ne 0 &lt;BR /&gt; then HCC_CODE = input(dx_cd(i),$testfmt.);&lt;BR /&gt;end;&lt;BR /&gt;end;&lt;BR /&gt;drop i;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Oct 2013 21:42:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Long-if-then/m-p/129265#M35242</guid>
      <dc:creator>Marina</dc:creator>
      <dc:date>2013-10-30T21:42:07Z</dc:date>
    </item>
  </channel>
</rss>

