<?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 Creating a table for my client (second attempt) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530752#M145158</link>
    <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a table (please see an attached file) from the data set below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA data1;&lt;BR /&gt;input id age sex exp;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 1 1 0&lt;BR /&gt;2 2 2 1&lt;BR /&gt;3 3 2 0&lt;BR /&gt;4 1 2 1&lt;BR /&gt;5 1 1 1&lt;BR /&gt;6 3 1 1&lt;BR /&gt;7 1 1 0&lt;BR /&gt;8 2 2 0&lt;BR /&gt;9 1 1 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get numbers running multiple 'proc freq';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=data1 out=data1_sort; by exp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age sex;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table sex;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I have to copy and paste the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way(s) to get the table directly from the data set without copying and pasting results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;</description>
    <pubDate>Mon, 28 Jan 2019 20:10:24 GMT</pubDate>
    <dc:creator>Yoko</dc:creator>
    <dc:date>2019-01-28T20:10:24Z</dc:date>
    <item>
      <title>Creating a table for my client (second attempt)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530752#M145158</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create a table (please see an attached file) from the data set below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA data1;&lt;BR /&gt;input id age sex exp;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 1 1 0&lt;BR /&gt;2 2 2 1&lt;BR /&gt;3 3 2 0&lt;BR /&gt;4 1 2 1&lt;BR /&gt;5 1 1 1&lt;BR /&gt;6 3 1 1&lt;BR /&gt;7 1 1 0&lt;BR /&gt;8 2 2 0&lt;BR /&gt;9 1 1 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can get numbers running multiple 'proc freq';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=data1 out=data1_sort; by exp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age sex;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table sex;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, I have to copy and paste the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way(s) to get the table directly from the data set without copying and pasting results?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yoko&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 20:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530752#M145158</guid>
      <dc:creator>Yoko</dc:creator>
      <dc:date>2019-01-28T20:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table for my client (second attempt)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530790#M145172</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=DATA1_SORT;
  table AGE / out=AGE;
  by EXP;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Jan 2019 21:06:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530790#M145172</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-01-28T21:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table for my client (second attempt)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530792#M145174</link>
      <description>&lt;P&gt;Sure, where you do you want the results, PDF or RTF (will open as word document) or Excel?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods pdf file='/folders/myfolders/myPDF.pdf' style=journal;
ods excel file = '/folders/myfolders/myExcel.xlsx' style = journal;
ods rtf file =  '/folders/myfolders/myRTF.rtf' style=journal;

proc freq data=data1_sort;
table age sex;
run;

 

proc freq data=data1_sort;
table age;
by exp;
run;

 

proc freq data=data1_sort;
table sex;
by exp;
run;

ods rtf close;
ods pdf close;
ods excel close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/152732"&gt;@Yoko&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to create a table (please see an attached file) from the data set below:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA data1;&lt;BR /&gt;input id age sex exp;&lt;BR /&gt;DATALINES;&lt;BR /&gt;1 1 1 0&lt;BR /&gt;2 2 2 1&lt;BR /&gt;3 3 2 0&lt;BR /&gt;4 1 2 1&lt;BR /&gt;5 1 1 1&lt;BR /&gt;6 3 1 1&lt;BR /&gt;7 1 1 0&lt;BR /&gt;8 2 2 0&lt;BR /&gt;9 1 1 0&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can get numbers running multiple 'proc freq';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=data1 out=data1_sort; by exp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age sex;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table age;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc freq data=data1_sort;&lt;BR /&gt;table sex;&lt;BR /&gt;by exp;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But, I have to copy and paste the results.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way(s) to get the table directly from the data set without copying and pasting results?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yoko&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 21:07:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530792#M145174</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-28T21:07:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table for my client (second attempt)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530799#M145177</link>
      <description>&lt;P&gt;It would help to provide some example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also the forum seems to be having an issue with allowing us to see attachments as yours is appearing with a "virus scan running" and is unavailable at this time. It may mean that you need to post the attached in a different file format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you actually need the cumulative counts and percentages for the Age and Sex one-way tables?&lt;/P&gt;
&lt;P&gt;If you don't need the cumulative bits perhaps proc tabulate will work though the age by sex table would look a bit different.&lt;/P&gt;
&lt;P&gt;Here is one example using a created data set to have similar variables that might get you started:&lt;/P&gt;
&lt;PRE&gt;data example;
   set sashelp.class;
   exp = rand('table',.3,.7);
run;


proc tabulate data=example;
   class exp age sex;
   table age, sex*(n pctn colpctn rowpctn);&lt;BR /&gt;   table age all, sex all;
   table exp, age,(n colpctn);
   table exp, sex,(n colpctn);
run;&lt;/PRE&gt;
&lt;P&gt;A big caveat for using proc tabulate in this manner is if any of the variables that appear on a CLASS statement have missing values then by default the entire record is excluded from the counts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jan 2019 21:20:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-table-for-my-client-second-attempt/m-p/530799#M145177</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-01-28T21:20:15Z</dc:date>
    </item>
  </channel>
</rss>

