<?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 to create a cross sectional table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/619243#M181762</link>
    <description>&lt;P&gt;Data is nice. Example data in the form of data step is best.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you run that data step and look at results?&lt;/P&gt;
&lt;P&gt;I suspect that you have nearly one third of your Tertile values may be missing because in this&amp;nbsp; code:&lt;/P&gt;
&lt;PRE&gt;if PCR_URINE_COMBINED&amp;lt; 0.062761506 then Tertile=1;
else if PCR_URINE_COMBINED=0.062761506-0.225225225 then Tertile=2;
else if PCR_URINE_COMBINED&amp;gt; 0.225225225 then Tertile=3;&lt;/PRE&gt;
&lt;P&gt;the&lt;/P&gt;
&lt;PRE&gt;=0.062761506-0.225225225 &lt;/PRE&gt;
&lt;P&gt;is NOT a range of values.&lt;/P&gt;
&lt;P&gt;Consider this example data set:&lt;/P&gt;
&lt;PRE&gt;data example;
   input PCR_URINE_COMBINED;
   if PCR_URINE_COMBINED&amp;lt; 0.062761506 then Tertile=1; 
   else if PCR_URINE_COMBINED=0.062761506-0.225225225 then Tertile=2; 
   else if PCR_URINE_COMBINED&amp;gt; 0.225225225 then Tertile=3;
datalines;
0.062761
0.062761506
0.062762
0.225225225
0.225226
;&lt;/PRE&gt;
&lt;P&gt;and see if the Tertile values are as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does allow use of code like&lt;/P&gt;
&lt;PRE&gt;   else if 0.062761506 le PCR_URINE_COMBINED le 0.225225225 then Tertile=2; 
&lt;/PRE&gt;
&lt;P&gt;where LE is "less than or equal" to indicate a range of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you show a table such as your "want to create" it really helps to provide example starting data and the expected values.&lt;/P&gt;
&lt;P&gt;I am not actually sure what your "&amp;nbsp;Mean (se)/N(%)" is supposed to be. Mean of what? SE I would typically expect to be a standard error, if so of what? Since your rows have % then it really is hard to envision what is meant by the column headings especially without any data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Rank in this case is likely in the wrong place. That would be used on the raw data BEFORE adding your TERTILE variable and could be used to create a variable indicating which group a variable is in based on the values to create the Tertiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A brief example using data you should have available:&lt;/P&gt;
&lt;PRE&gt;proc rank data=sashelp.class groups=3 
   out=work.agetertiles;
   var age;
   ranks agetertile;
run;&lt;/PRE&gt;
&lt;P&gt;And creating a report with the agetertiles as columns and count and percents of sex within the column&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=work.agetertiles;
   class agetertile;
   class sex;
   tables sex,
          agetertile*(colpctn n)
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Note that Proc Rank starts at 0 not 1 for the ranks. So to get 1, 2 and 3 you would need to do something such as pass the data through a data step before the report procedure.&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jan 2020 17:30:06 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-01-22T17:30:06Z</dc:date>
    <item>
      <title>How to create a cross sectional table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/619227#M181755</link>
      <description>&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;PCR_URINE_COMBINE&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;&lt;/SPAN&gt;&lt;SPAN&gt;First Tertile&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Second Tertile&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Third Tertile&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; Mean (se)/N(%)&amp;nbsp; &amp;nbsp; &amp;nbsp; Mean (se)/N(%)&amp;nbsp; &amp;nbsp; &amp;nbsp; Mean (se)/N(%)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;White(%)&lt;/P&gt;&lt;P&gt;Male(%)&lt;/P&gt;&lt;P&gt;Age(yrs)&lt;/P&gt;&lt;P&gt;EGFR(%)&lt;/P&gt;&lt;P&gt;&amp;gt;60&lt;/P&gt;&lt;P&gt;45-60&lt;/P&gt;&lt;P&gt;30-45&lt;/P&gt;&lt;P&gt;&amp;lt;30&lt;/P&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;This is my table and I want to create a cross sectional table.&lt;/P&gt;&lt;P&gt;About the variable&amp;nbsp;&lt;SPAN&gt;PCR_URINE_COMBINE, my code is:&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=PROJECT.PAPER_CRIC; var PCR_URINE_COMBINED; output out=perc pctlpre=p_ pctlpts= 33.33 66.67; run;&lt;/P&gt;&lt;P&gt;I knew the two points of this variable(0.062761506,&amp;nbsp;0.225225225 ) from the sas output, and next I need to divide into three parts (first,2nd,3rd)of this variable, that is from continuous variable to categorical variable. I read the message from you told me (like proc rank....), but i am still confused how to produce my table (Like&amp;nbsp; proc means,&amp;nbsp; &amp;nbsp;proc freq....). I write some codes, but i don't know how to write more...Can someone help revise my codes or give some sample code for me? Sorry for my rough draft of codes.&amp;nbsp;&lt;SPAN class="high-light"&gt;I&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="high-light"&gt;really&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="high-light"&gt;appreciate&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="high-light"&gt;your&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data CRIC;&lt;BR /&gt;set PROJECT.PAPER_CRIC;&lt;/P&gt;&lt;P&gt;if WHITE='White' and SEX='Male';&lt;/P&gt;&lt;P&gt;format group $8.;&lt;/P&gt;&lt;P&gt;if EGFR_CKD_EPI&amp;lt;30 then&lt;BR /&gt;group='&amp;lt;30';&lt;/P&gt;&lt;P&gt;if EGFR_CKD_EPI&amp;gt;=30 and EGFR_CKD_EPI&amp;lt;45 then&lt;BR /&gt;group='30-45';&lt;/P&gt;&lt;P&gt;if EGFR_CKD_EPI&amp;gt;=45 and EGFR_CKD_EPI&amp;lt;60 then&lt;BR /&gt;group='45-60';&lt;/P&gt;&lt;P&gt;if EGFR_CKD_EPI&amp;gt;=60 then&lt;BR /&gt;group='&amp;gt;60';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ATTRIB Tertile&amp;nbsp; LENGTH = 8&amp;nbsp; LABEL = "Tertile";&lt;/P&gt;&lt;P&gt;if PCR_URINE_COMBINED&amp;lt; 0.062761506 then Tertile=1;&lt;BR /&gt;else if PCR_URINE_COMBINED=0.062761506-0.225225225 then Tertile=2;&lt;BR /&gt;else if PCR_URINE_COMBINED&amp;gt; 0.225225225 then Tertile=3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc rank data=PROJECT.PAPER_CRIC groups=3 out=want;&lt;BR /&gt;var PCR_URINE_COMBINED;&lt;BR /&gt;ranks tertiles;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 16:52:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/619227#M181755</guid>
      <dc:creator>peiy5920</dc:creator>
      <dc:date>2020-01-22T16:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a cross sectional table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/619243#M181762</link>
      <description>&lt;P&gt;Data is nice. Example data in the form of data step is best.&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Did you run that data step and look at results?&lt;/P&gt;
&lt;P&gt;I suspect that you have nearly one third of your Tertile values may be missing because in this&amp;nbsp; code:&lt;/P&gt;
&lt;PRE&gt;if PCR_URINE_COMBINED&amp;lt; 0.062761506 then Tertile=1;
else if PCR_URINE_COMBINED=0.062761506-0.225225225 then Tertile=2;
else if PCR_URINE_COMBINED&amp;gt; 0.225225225 then Tertile=3;&lt;/PRE&gt;
&lt;P&gt;the&lt;/P&gt;
&lt;PRE&gt;=0.062761506-0.225225225 &lt;/PRE&gt;
&lt;P&gt;is NOT a range of values.&lt;/P&gt;
&lt;P&gt;Consider this example data set:&lt;/P&gt;
&lt;PRE&gt;data example;
   input PCR_URINE_COMBINED;
   if PCR_URINE_COMBINED&amp;lt; 0.062761506 then Tertile=1; 
   else if PCR_URINE_COMBINED=0.062761506-0.225225225 then Tertile=2; 
   else if PCR_URINE_COMBINED&amp;gt; 0.225225225 then Tertile=3;
datalines;
0.062761
0.062761506
0.062762
0.225225225
0.225226
;&lt;/PRE&gt;
&lt;P&gt;and see if the Tertile values are as expected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does allow use of code like&lt;/P&gt;
&lt;PRE&gt;   else if 0.062761506 le PCR_URINE_COMBINED le 0.225225225 then Tertile=2; 
&lt;/PRE&gt;
&lt;P&gt;where LE is "less than or equal" to indicate a range of values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you show a table such as your "want to create" it really helps to provide example starting data and the expected values.&lt;/P&gt;
&lt;P&gt;I am not actually sure what your "&amp;nbsp;Mean (se)/N(%)" is supposed to be. Mean of what? SE I would typically expect to be a standard error, if so of what? Since your rows have % then it really is hard to envision what is meant by the column headings especially without any data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Rank in this case is likely in the wrong place. That would be used on the raw data BEFORE adding your TERTILE variable and could be used to create a variable indicating which group a variable is in based on the values to create the Tertiles.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A brief example using data you should have available:&lt;/P&gt;
&lt;PRE&gt;proc rank data=sashelp.class groups=3 
   out=work.agetertiles;
   var age;
   ranks agetertile;
run;&lt;/PRE&gt;
&lt;P&gt;And creating a report with the agetertiles as columns and count and percents of sex within the column&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=work.agetertiles;
   class agetertile;
   class sex;
   tables sex,
          agetertile*(colpctn n)
   ;
run;&lt;/PRE&gt;
&lt;P&gt;Note that Proc Rank starts at 0 not 1 for the ranks. So to get 1, 2 and 3 you would need to do something such as pass the data through a data step before the report procedure.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 17:30:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/619243#M181762</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-01-22T17:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a cross sectional table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/620206#M182207</link>
      <description>Thanks for your detailed reply!</description>
      <pubDate>Mon, 27 Jan 2020 15:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-cross-sectional-table/m-p/620206#M182207</guid>
      <dc:creator>peiy5920</dc:creator>
      <dc:date>2020-01-27T15:53:56Z</dc:date>
    </item>
  </channel>
</rss>

