<?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 name a code and combinations of codes in a particular variable? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515683#M139174</link>
    <description>&lt;P&gt;This should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data obs_rad.SOB;
do until(last.id);
    set obs_rad.radft; by id;
    if hltcode in (262, 2727, 26252, 227272) then Whyz = 1;
    if hltcode in (626228, 227, 22772, 26252, 7383) then Emfy = 1;
    if hltcode in (73, 252, 27, 252, 262782, 5262, 27272, 27282, 2722, 272626, 25215, 526) then lgel = 1;
    if hltcode in (6316, 126137, 126316, 1351, 2636, 26317, 73171) then etope = 1;
    end;
if sum(Whyz, Emfy, lgel, etope) &amp;gt;= 3 or whyz and emfy then hlt_grp = "Pheno";
else if Emfy then hlt_grp = "Emfy";
else if Whyz then hlt_grp = "Whyz";
do until(last.id);
    set obs_rad.radft; by id;
    output;
    end;
drop Whyz Emfy lgel etope;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 23 Nov 2018 23:17:12 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2018-11-23T23:17:12Z</dc:date>
    <item>
      <title>How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515666#M139167</link>
      <description>&lt;P&gt;Please!&lt;/P&gt;&lt;P&gt;I have a data that has one of its variable called hltcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The hltcode variable have codes that denotes different features. I need to create another variable (called hlt_grp) and group Whyz, Emfy and Pheno based on a code or combination of codes from hltcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any of these codes in hltcode (35, 37, 38, 39, 484, 7827, 2728, 2539, 2218, 2721912) represent Whyz&amp;nbsp;&lt;/P&gt;&lt;P&gt;any one of these codes&amp;nbsp; (728, 7298, 722, 27218, 2721821, 27282, 27218)&amp;nbsp;&lt;SPAN&gt;represent&lt;/SPAN&gt;&amp;nbsp;Emfy&lt;/P&gt;&lt;P&gt;any one of these codes (73, 252, 27, 252, 262782, 5262, 27272, 27282, 2722, 272626, 25215,526)&amp;nbsp;&lt;SPAN&gt;represent&lt;/SPAN&gt;&amp;nbsp;Lgel&lt;/P&gt;&lt;P&gt;any one of these codes (6316, 126137, 126316, 1351, 2636, 26317, 73171) represent Etope&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore;&lt;/P&gt;&lt;P&gt;If a code in hltcode contains ANY code of Whyz, then it's Whyz.&lt;/P&gt;&lt;P&gt;If a code in hltcode contains ANY code of Emfy, then it's Emfy.&lt;/P&gt;&lt;P&gt;if a code in hltcode contains BOTH codes of Whyz AND Emfy, then it's Pheno.&lt;/P&gt;&lt;P&gt;if a code in hltcode should have a combination (3 combinations) of Whyz AND Emfy AND Lgel, then it's still Pheno&lt;/P&gt;&lt;P&gt;If a code in hltcode should have a combination (4 combinations) of Whyz AND Emfy AND Lgel AND Etope, then it's still Pheno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried series of SAS trials but don't seem to work out completely. Please any help?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 21:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515666#M139167</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-23T21:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515667#M139168</link>
      <description>&lt;P&gt;How is hltcode many codes at the same time?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 21:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515667#M139168</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-23T21:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515673#M139170</link>
      <description>&lt;P&gt;No please.&lt;/P&gt;&lt;P&gt;There is another variable called "ID";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Therefore; if&lt;/P&gt;&lt;P&gt;If an ID has a code in hltcode that contains only one code in Whyz, then it's Whyz.&lt;/P&gt;&lt;P&gt;If an ID has a code in hltcode that contains only one code in Emfy, then it's Emfy.&lt;/P&gt;&lt;P&gt;if an ID has a code in hltcode contains BOTH codes of Whyz AND Emfy, then it's Pheno.&lt;/P&gt;&lt;P&gt;if an ID has&amp;nbsp; combination of 3 codes of Whyz AND Emfy AND Lgel, then it's still Pheno&lt;/P&gt;&lt;P&gt;If an ID has&amp;nbsp;&lt;SPAN&gt;combination of 4 codes&lt;/SPAN&gt; of Whyz AND Emfy AND Lgel AND Etope, then it's still Pheno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, an ID have several observations for hltcode&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 21:54:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515673#M139170</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-23T21:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515677#M139171</link>
      <description>Please show an example of what your input data looks like and what you expect as output.</description>
      <pubDate>Fri, 23 Nov 2018 22:38:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515677#M139171</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-23T22:38:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515681#M139173</link>
      <description>&lt;P&gt;***////This is an example of my input data into SAS look like. The codes in the bracket are not necessary what they represented///*****;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;libname obs_rad "C:\obs_rad";&lt;/P&gt;&lt;P&gt;data obs_rad.radft;&lt;/P&gt;&lt;P&gt;set obs_rad.radft;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data obs_rad.SOB;&lt;/P&gt;&lt;P&gt;set obs_rad.radft;&lt;/P&gt;&lt;P&gt;if hltcode in (262, 2727, 26252, 227272) then alc_grp="Whyz";&lt;/P&gt;&lt;P&gt;if hltcode in (626228, 227, 22772, 26252, 7383) then alc_grp="Emfy";&lt;/P&gt;&lt;P&gt;if hltcode in (636, 6363, 4484, 37393, 383839, 393, 3737) and hltcode in (636, 2262, 2627, 26272) then alc_grp="Pheno";&lt;/P&gt;&lt;P&gt;if hltcode in&amp;nbsp;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;262, 2727, 26252, 227272) and hltcode in (636, 6363, 4484, 37393, 383839, 393, 3737) and hitcode in&amp;nbsp;636, 2262, 2627, 26272) then alc_grp="Pheno";&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc freq data=obs_rad.SOB;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;table alc_grp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 22:55:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515681#M139173</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-23T22:55:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515683#M139174</link>
      <description>&lt;P&gt;This should do it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data obs_rad.SOB;
do until(last.id);
    set obs_rad.radft; by id;
    if hltcode in (262, 2727, 26252, 227272) then Whyz = 1;
    if hltcode in (626228, 227, 22772, 26252, 7383) then Emfy = 1;
    if hltcode in (73, 252, 27, 252, 262782, 5262, 27272, 27282, 2722, 272626, 25215, 526) then lgel = 1;
    if hltcode in (6316, 126137, 126316, 1351, 2636, 26317, 73171) then etope = 1;
    end;
if sum(Whyz, Emfy, lgel, etope) &amp;gt;= 3 or whyz and emfy then hlt_grp = "Pheno";
else if Emfy then hlt_grp = "Emfy";
else if Whyz then hlt_grp = "Whyz";
do until(last.id);
    set obs_rad.radft; by id;
    output;
    end;
drop Whyz Emfy lgel etope;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Nov 2018 23:17:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515683#M139174</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-23T23:17:12Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515684#M139175</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Nov 2018 23:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515684#M139175</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-23T23:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515689#M139177</link>
      <description>&lt;P&gt;However, i need some clarifications.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. My 3 distinct groups are Whyz, Emfy or Pheno. That means each of my ID has to be grouped into either Whyz, Emfy or Pheno. In your last SAS statement, you coded:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE class="  language-sas"&gt;drop Whyz Emfy lgel etope&lt;/CODE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Also, if an ID with a hltcode of both Whyz AND Emfy = Pheno&lt;/P&gt;&lt;P&gt;&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; hltcode of both Whyz AND Etope = Pheno&lt;/P&gt;&lt;P&gt;&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;SPAN&gt;hltcode of both Emfy AND Lgel = Pheno&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; hltcode of Emfy, Lgel, Etope = Pheno&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&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; hltcode of both Polp AND Lopr= Pheno&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Actually i have 13 features: Whyz, Emfy, Etope, Lgel, Etope, Polp, Klig, Uttr, Thaip, Ghait, Dondj, Lopr, Bduc.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It can be a combination of any two only, three only or four only which i have to define based on the definition in the literature.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;There is a code for Pheno only as well, which needs no combination but represent "Pheno".&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Nov 2018 00:37:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515689#M139177</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-24T00:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515702#M139187</link>
      <description>&lt;P&gt;&lt;STRONG&gt;How the code works&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;In the code above, variables whyz, emfy, lgel, and etope are all missing at the start of an ID group. In the first do until() loop, as soon as a proper code is found, the variable becomes = 1.&lt;/P&gt;
&lt;P&gt;The IF THEN ELSE IF... statements transform the combination of features into the&amp;nbsp;corresponding value for hlt_grp.&lt;/P&gt;
&lt;P&gt;The last loop simply copies the ID group to the output with the new variable hlt_grp.&lt;/P&gt;
&lt;P&gt;The variables whyz, emfy, lgel, and etope&amp;nbsp;are not needed in the output, so they are dropped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Adding more features&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;The code above involved only the 4 features&amp;nbsp;presented in&amp;nbsp;your original question.&amp;nbsp;With 13 features being&amp;nbsp;possibly present or absent in&amp;nbsp;each ID group, you will&amp;nbsp;have 2^13 = 8192 combinations to account for. The logic could get out of hand unless it can be summarized into a small set of rules.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 24 Nov 2018 04:58:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515702#M139187</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-11-24T04:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515707#M139192</link>
      <description>I'd suggest user-defined formats to manage and define the hit-code groups., PROC summary or means to collect hit-code groups per ID and some scoring system to translate combinations of hit-grp to the target results.&lt;BR /&gt;PROC FORMAT and MEANS  examples should give good direction.</description>
      <pubDate>Sat, 24 Nov 2018 07:22:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515707#M139192</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-24T07:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515708#M139193</link>
      <description>PROC summary data=your data NWAY ;&lt;BR /&gt;Class id hitcode ;&lt;BR /&gt;Format hitcode udef_fmt;&lt;BR /&gt;Output out= idgroups n=count ;&lt;BR /&gt;Run ;&lt;BR /&gt; &lt;BR /&gt;* now create a hit groups collection  for ID;&lt;BR /&gt;Data combine;&lt;BR /&gt;Do until(  last.id ) ;&lt;BR /&gt;   Set idgroups ;&lt;BR /&gt;   Length hit_grp $100 ;&lt;BR /&gt;   Hit_grp = catx( '-', hit_gdp, put( hit-code, udef_fmt. ) )  ;&lt;BR /&gt;End ;&lt;BR /&gt;Run ;&lt;BR /&gt;* now process your rules on collection hit_grp;</description>
      <pubDate>Sat, 24 Nov 2018 07:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515708#M139193</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-24T07:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: How do I name a code and combinations of codes in a particular variable?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515709#M139194</link>
      <description>Sorry about the autocorrect and typos&lt;BR /&gt;udef_fmt&lt;BR /&gt;Has no dot(.) only when you create it in PROC FORMAT &lt;BR /&gt;HIT_GDP should be hit_grp &lt;BR /&gt;HIT-CODE should be hitcode&lt;BR /&gt; &lt;BR /&gt;Wish this samsung internet browser supported the code formatting.&lt;BR /&gt;</description>
      <pubDate>Sat, 24 Nov 2018 07:42:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-name-a-code-and-combinations-of-codes-in-a-particular/m-p/515709#M139194</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2018-11-24T07:42:00Z</dc:date>
    </item>
  </channel>
</rss>

