<?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 code a group of codes as Pheno and combination of 2 or more codes as Pheno? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516349#M139456</link>
    <description>&lt;P&gt;I was able to get around it.&lt;/P&gt;&lt;P&gt;Firstly i created new variables for all my groups of interest.&lt;/P&gt;&lt;P&gt;Then using IF, OR and THEN statements i was able to create my Pheno group.&lt;/P&gt;&lt;P&gt;Finally, defining a new variable and using IF statement, i was able to create my three exclusive groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 27 Nov 2018 15:35:24 GMT</pubDate>
    <dc:creator>Mystik</dc:creator>
    <dc:date>2018-11-27T15:35:24Z</dc:date>
    <item>
      <title>How do i code a group of codes as Pheno and combination of 2 or more codes as Pheno?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/515845#M139251</link>
      <description>&lt;P&gt;I have been working around this since Friday, can't seem to get around it.&lt;/P&gt;&lt;P&gt;Let me present my case again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have over 232million observations.&lt;/P&gt;&lt;P&gt;I need to categorize my IDs into 3 groups. Namely Whyz, Emfy and Pheno based on codes which an ID has in hltcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID's have more than one observations for hltcode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If an ID have only one of the following codes (&lt;SPAN&gt;35, 37, 38, 39, 484, 7827, 2728, 2539, 2218, 2721912&lt;/SPAN&gt;) in hltcode then it is Whyz.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If an ID have only one of the following codes (728, 7298, 722, 27218, 2721821, 27282, 27218)&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;in hltcode then it is Emfy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; However if an ID have both Whyz code AND Emfy code in hltcode then that ID needs to categorized as Pheno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, If any ID have any of these codes (637383, 35363, 9830) then that ID also have to be categorized as Pheno.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, there are other 5 groups, called&amp;nbsp;&lt;SPAN&gt;Klig, Uttr, Thaip, Ghait, Dondj&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;the hltcode for Klig are (6373, 3633, 73392, 11928, 638383, 362892, 3691101)&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;Uttr are (7748, 373229, 372382, 363763, 36373)&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;Thaip are (872920,647474, 3731738, 646)&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;Ghait are (77747, 6377, 36787, 46478498, 738991)&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;Dondj are (7733, 63599, 37383, 3663, 37137)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Whyz AND Klig then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Whyz AND Klig AND Dondj then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Whyz AND Thaip AND Dondj then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Emfy AND Thaip then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Emfy AND Utter AND Thaip then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Emfy AND Dondj AND Thaip then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if any ID have a hltcode for Emfy AND Klig AND Dondj then&amp;nbsp;that ID also have to be categorized also as Pheno.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was what i tried doing but realized that was not appropriate based on suggestions in SAS community.&amp;nbsp;&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&amp;nbsp;&lt;SPAN&gt;(637383, 35363, 9830) then alc_grp="Pheno";&lt;/SPAN&gt;&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;</description>
      <pubDate>Sun, 25 Nov 2018 22:58:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/515845#M139251</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-25T22:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: How do i code a group of codes as Pheno and combination of 2 or more codes as Pheno?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/515855#M139254</link>
      <description>&lt;P&gt;I understand that relevant input variables are just two: ID and HLTCODE and that there may be more than one observation per ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of using&amp;nbsp;&lt;STRONG&gt;if hltcode in (...)&lt;/STRONG&gt; I would prefer build a format:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format lib=work;   /* or any library to save the format */
   value grp
       35,37-39,484,7827, ...     = 'Whyz'
       728,7298,722,2721821 .... = 'Emfy'
      ...........
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;next step will be to assign value to alc_grp&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data temp;
 set have;
      alc_grp = put(hltcode, grp. );
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;last step is to check is there a single value of alc_grp per ID or more and create output with one observation per ID&lt;/P&gt;
&lt;P&gt;containing ID and alt_grp as only variables. That can be done by sql or by a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set temp (keep=ID alt_grp);
  by ID;
      length group $5; 
      retain group;
      drop group;

      if first.ID then group = alt_grp; else
      if alt_grp NE group then group = 'Pheno';
      if last.ID then do;
        alt_grp = group;
        output;
     end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Nov 2018 00:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/515855#M139254</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-11-26T00:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do i code a group of codes as Pheno and combination of 2 or more codes as Pheno?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516030#M139335</link>
      <description>&lt;P&gt;Thank you.&lt;BR /&gt;I was able to execute the 1st step however,&lt;BR /&gt;i got an Error: the Format GRP was not found or could not be loaded.&lt;/P&gt;&lt;P&gt;Can you pls give me some clarifications in the 2nd step;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data "temp";&lt;/P&gt;&lt;P&gt;set "have";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what specifically should "temp" and "have" denote?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 16:03:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516030#M139335</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-26T16:03:24Z</dc:date>
    </item>
    <item>
      <title>Re: How do i code a group of codes as Pheno and combination of 2 or more codes as Pheno?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516103#M139370</link>
      <description>&lt;P&gt;1st step creates the format grp. in work.formats catalog.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2nd step add the alt_grp as required per observation.&lt;/P&gt;
&lt;P&gt;Please &lt;STRONG&gt;post your full log&lt;/STRONG&gt; with the exact error message.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;3rd step alters alt_grp depending on values exist in same ID observations.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Nov 2018 19:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516103#M139370</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2018-11-26T19:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do i code a group of codes as Pheno and combination of 2 or more codes as Pheno?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516349#M139456</link>
      <description>&lt;P&gt;I was able to get around it.&lt;/P&gt;&lt;P&gt;Firstly i created new variables for all my groups of interest.&lt;/P&gt;&lt;P&gt;Then using IF, OR and THEN statements i was able to create my Pheno group.&lt;/P&gt;&lt;P&gt;Finally, defining a new variable and using IF statement, i was able to create my three exclusive groups.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 27 Nov 2018 15:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-i-code-a-group-of-codes-as-Pheno-and-combination-of-2-or/m-p/516349#M139456</guid>
      <dc:creator>Mystik</dc:creator>
      <dc:date>2018-11-27T15:35:24Z</dc:date>
    </item>
  </channel>
</rss>

