<?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: Creating tertiles based on a control group in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719459#M9749</link>
    <description>That part of the code isn't what I had a question on, I know it is correct. I was just including it for some context.</description>
    <pubDate>Mon, 15 Feb 2021 19:35:58 GMT</pubDate>
    <dc:creator>gejoachim99</dc:creator>
    <dc:date>2021-02-15T19:35:58Z</dc:date>
    <item>
      <title>Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719231#M9742</link>
      <description>&lt;P&gt;I want to create tertiles to organize my data into categories. However, I want the tertiles to be made based off of the control group. I tried this code, but then when I run the proc freq the table only shows data when casecont_path=1. How do I create tertiles using one group, then apply it to both the cases and the controls?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc rank data=work.adenovar groups=3;&lt;BR /&gt;where casecont_path=1;&lt;BR /&gt;var jointyears;&lt;BR /&gt;ranks jointyears_tert;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*categorical joint years*/&lt;BR /&gt;data work.adeno1;&lt;BR /&gt;set work.data1;&lt;BR /&gt;if hash=2 then jointyears_cat=0;&lt;BR /&gt;if jointyears_tert=0 then jointyears_cat=1;&lt;BR /&gt;if jointyears_tert=1 then jointyears_cat=2;&lt;BR /&gt;if jointyears_tert=2 then jointyears_cat=3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=work.adeno1;&lt;BR /&gt;tables jointyears_cat*casecont_path/norow nopercent;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 20:39:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719231#M9742</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-02-14T20:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719233#M9743</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where casecont_path=1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so when you get to PROC FREQ, it never finds any other value for variable CASECONT_PATH.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A useful debugging method is for you to actually look at the data sets with your own eyes and see what is in there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 21:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719233#M9743</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-02-14T21:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719234#M9744</link>
      <description>I understand that the where statement is why the proc freq isn't what I need, but I'm more asking if there is a way to create tertiles based on only that group, then apply that categorization to both my cases and controls. My data set is very large.</description>
      <pubDate>Sun, 14 Feb 2021 21:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719234#M9744</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-02-14T21:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719235#M9745</link>
      <description>&lt;P&gt;Why not use proc univariate to make two cut-points, at the 33.33%ile and 66.67%ile values?&amp;nbsp; This is a good way to avoid&lt;EM&gt;&lt;STRONG&gt; holes from the proc rank on a subset.&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; (edit: failed to paste this additional text).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=work.adenovar noprint;;
  where casecont_path=1;
  var jointyears;
  output out=need pctlpts=33.33 66.67 pctlpre=pctl ;
run;

/*categorical joint years*/
data work.adeno1 (drop=pctl33_33 pctl_66_67);
  set work.data1;
  if _n_=1 then set need; 
  if hash=2 then jointyears_cat=0; else
  jointyears=1 + (jointyears&amp;gt;pctl33_33) + (jointyears&amp;gt;pctl66_67);
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;Dataset need will have one observation with two variables PCTL33_33, and PCTL66_67.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The "if _n_=1 then set need;" statement reads the single NEED observation during only the first iteration of the data step.&amp;nbsp; Otherwise it would attempt to read beyond the end of NEED, and the data step would stop prematurely.&amp;nbsp; &amp;nbsp;And all the variables read by that conditional SET NEED statement will be retained for use in all subsequent obs as you progress through work.adeno1.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 15 Feb 2021 14:51:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719235#M9745</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-02-15T14:51:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719276#M9747</link>
      <description>&lt;P&gt;This code&lt;/P&gt;
&lt;PRE&gt;data work.adeno1;
set work.data1;
if hash=2 then jointyears_cat=0;
if jointyears_tert=0 then jointyears_cat=1;
if jointyears_tert=1 then jointyears_cat=2;
if jointyears_tert=2 then jointyears_cat=3;
run;&lt;/PRE&gt;
&lt;P&gt;is very likely overwriting the value of jointyears_cat set when hash=2 unless "joint_years_tert" is missing.&lt;/P&gt;
&lt;P&gt;You might be wanting&lt;/P&gt;
&lt;PRE&gt;data work.adeno1;
   set work.data1;
   if hash=2 then jointyears_cat=0;
   Else Jointyears_cat = jointyears_tert +1;
run;&lt;/PRE&gt;
&lt;P&gt;Be prepared to provide example data and expected result for that example.&lt;/P&gt;
&lt;P&gt;The "application" to other variables can be extremely data dependendent&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 07:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719276#M9747</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-15T07:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719459#M9749</link>
      <description>That part of the code isn't what I had a question on, I know it is correct. I was just including it for some context.</description>
      <pubDate>Mon, 15 Feb 2021 19:35:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719459#M9749</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-02-15T19:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719460#M9750</link>
      <description>&lt;P&gt;After some more thought, I think I'm asking the wrong question. I know how to divide up my data into tertiles, and I now understand how to do it for just my control group. What I really need to know now is how to see what each tertile actually is, like it's numerical value, so I can use it in making categories.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Feb 2021 19:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719460#M9750</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-02-15T19:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719465#M9752</link>
      <description>&lt;P&gt;Then run the PROC UNIVARITATE I showed, and do a PROC PRINT of the NEED dataset produced by it.&amp;nbsp; &amp;nbsp;If this were other, more standard percentiles, then you could drop the "NOPRINT" option and see the percentile reported by PROC UNIVARIATE.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or, in the DATA step assigning tertiles, just add a&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if _n_=1 then put (pctl:) (=);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;statement after the "set need" statement.&lt;/P&gt;
&lt;P&gt;============================== editted comments below ================================&lt;/P&gt;
&lt;P&gt;This above was marked as a "solution", but it's really only the answer to a derivative question, and doesn't really connect with the subject line.&amp;nbsp; So I've included below my original response, which will give context to the above:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc univariate data=work.adenovar noprint;;
  where casecont_path=1;
  var jointyears;
  output out=need pctlpts=33.33 66.67 pctlpre=pctl ;
run;

/*categorical joint years*/
data work.adeno1 (drop=pctl33_33 pctl_66_67);
  set work.data1;
  if _n_=1 then set need; 
  if _n_=1 then put (pctl:) (=);   /* Added in response to follow-up*/
  if hash=2 then jointyears_cat=0; else
  jointyears=1 + (jointyears&amp;gt;pctl33_33) + (jointyears&amp;gt;pctl66_67);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;Dataset need will have one observation with two variables PCTL33_33, and PCTL66_67.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;The "if _n_=1 then set need;" statement reads the single NEED observation during only the first iteration of the data step.&amp;nbsp; Otherwise it would attempt to read beyond the end of NEED, and the data step would stop prematurely.&amp;nbsp; &amp;nbsp;And all the variables read by that conditional SET NEED statement will be retained for use in all subsequent obs as you progress through work.adeno1.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Mon, 15 Feb 2021 21:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719465#M9752</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-02-15T21:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating tertiles based on a control group</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719466#M9753</link>
      <description>Thank you so much! That worked! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 15 Feb 2021 20:00:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Creating-tertiles-based-on-a-control-group/m-p/719466#M9753</guid>
      <dc:creator>gejoachim99</dc:creator>
      <dc:date>2021-02-15T20:00:17Z</dc:date>
    </item>
  </channel>
</rss>

