<?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 Help with creating a new table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-a-new-table/m-p/938034#M368509</link>
    <description>&lt;P&gt;Hi, I am using the YRBS dataset. I'd like to create a new table with just a few columns from an existing dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current code, which does *not* work:&lt;/P&gt;&lt;PRE&gt;data work.yrbs2007 (Keep = Age Sex Grade RaceEthnicity Inclusion Survey_Year Sunscreen_Binary BMICategory);
run;&lt;/PRE&gt;&lt;P&gt;How do I create a new table (let's call it work.yrbs2007mod) from my existing datatable (work.yrbs2007) with a few selected columns (Age Sex Grade RaceEthnicity Inclusion Survey_Year Sunscreen_Binary BMICategory)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 01 Aug 2024 22:47:23 GMT</pubDate>
    <dc:creator>ronaldo7</dc:creator>
    <dc:date>2024-08-01T22:47:23Z</dc:date>
    <item>
      <title>Help with creating a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-a-new-table/m-p/938034#M368509</link>
      <description>&lt;P&gt;Hi, I am using the YRBS dataset. I'd like to create a new table with just a few columns from an existing dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my current code, which does *not* work:&lt;/P&gt;&lt;PRE&gt;data work.yrbs2007 (Keep = Age Sex Grade RaceEthnicity Inclusion Survey_Year Sunscreen_Binary BMICategory);
run;&lt;/PRE&gt;&lt;P&gt;How do I create a new table (let's call it work.yrbs2007mod) from my existing datatable (work.yrbs2007) with a few selected columns (Age Sex Grade RaceEthnicity Inclusion Survey_Year Sunscreen_Binary BMICategory)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2024 22:47:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-a-new-table/m-p/938034#M368509</guid>
      <dc:creator>ronaldo7</dc:creator>
      <dc:date>2024-08-01T22:47:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with creating a new table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-a-new-table/m-p/938038#M368513</link>
      <description>&lt;P&gt;The name that goes on the DATA statement is the name of the NEW dataset.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You would put the name of the OLD dataset on the SET statement.&amp;nbsp; What is the name of the current YBRS dataset?&amp;nbsp; Let's assume it is named YRBS2007 and it is in the directory that you pointed the MYLIB libref towards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then your could should look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data my_subset;
  set mylib.yrbs2007;
  keep Age Sex Grade RaceEthnicity Inclusion Survey_Year 
       Sunscreen_Binary BMICategory
  ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For your problem description you should not need to add any dataset options on the output dataset name.&amp;nbsp; &amp;nbsp;In fact there is probably no need to use dataset options at all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It might be a tiny bit more efficient to use a KEEP= dataset option on the source dataset read by the SET statement.&amp;nbsp; But it probably is not really worth making the code more complicated just to do that.&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>Fri, 02 Aug 2024 01:38:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-creating-a-new-table/m-p/938038#M368513</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-02T01:38:50Z</dc:date>
    </item>
  </channel>
</rss>

