<?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: exporting subset of data from sas7bdat to csv in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483274#M71700</link>
    <description>&lt;P&gt;You just need the need to add keep= Var1 Var2 ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data='LibraryReference.FileName(keep=Vars-to-export-separated-by-blank'
    outfile='/folders/myfolders/Folder where I want it exported/new csv file name'
    dbms=csv
    replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.class(keep=Name Age) 
      dbms=csv
      outfile="INSERT_PATH\class.csv"
      replace
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 02 Aug 2018 05:21:57 GMT</pubDate>
    <dc:creator>andreas_lds</dc:creator>
    <dc:date>2018-08-02T05:21:57Z</dc:date>
    <item>
      <title>exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483250#M71698</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS University Edition on my MAC and have a huge data set (&amp;gt;2200 variables) saved in a sas7bdat format a colleague provided to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I&amp;nbsp;export just selected variables (&amp;lt;100) and have it exported to csv format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried opening the file from my shared folders in SAS studio, clicking on just the variables from the columns section (in the work area) then writing the following export code:&lt;/P&gt;&lt;P&gt;proc export data='LibraryReference.FileName'&lt;/P&gt;&lt;P&gt;outfile='/folders/myfolders/Folder where I want it exported/new csv file name'&lt;/P&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the entire data sets gets exported. Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks - J&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 02:36:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483250#M71698</guid>
      <dc:creator>jenfumi</dc:creator>
      <dc:date>2018-08-02T02:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483262#M71699</link>
      <description>&lt;P&gt;You're close!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When you look at the data set and select the variables that you want, you can click on an icon near the top of the screen to display the code that creates the current table.&amp;nbsp; The red arrow in the screen shot below is pointing to the icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Icon at the top of the screen will display the code that creates the current table" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22161i99C6319AEF708B6A/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS University Editon can show you the code that generates the current table.jpg" alt="Icon at the top of the screen will display the code that creates the current table" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Icon at the top of the screen will display the code that creates the current table&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;When you click on that icon, a new program tab will open.&amp;nbsp; In the screen shot below, the PROC SQL creates the WORK.query data set.&amp;nbsp; That's what I'll export to CSV.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Code in the red box at the top of the screen is generated by the icon on the data set tab" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22162i14AB5ED9CFF98429/image-size/large?v=v2&amp;amp;px=999" role="button" title="Code generated after clicking on icon when viewing the data set.jpg" alt="Code in the red box at the top of the screen is generated by the icon on the data set tab" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Code in the red box at the top of the screen is generated by the icon on the data set tab&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I opened up my CSV file in Notepad in the screen shot below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="CSV file with 3 variables from SASHELP.BASEBALL data set" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22163i7EE26C5C12236567/image-size/large?v=v2&amp;amp;px=999" role="button" title="CSV with a few variables from SASHELP BASEBALL data set.jpg" alt="CSV file with 3 variables from SASHELP.BASEBALL data set" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;CSV file with 3 variables from SASHELP.BASEBALL data set&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 04:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483262#M71699</guid>
      <dc:creator>SuzanneDorinski</dc:creator>
      <dc:date>2018-08-02T04:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483274#M71700</link>
      <description>&lt;P&gt;You just need the need to add keep= Var1 Var2 ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data='LibraryReference.FileName(keep=Vars-to-export-separated-by-blank'
    outfile='/folders/myfolders/Folder where I want it exported/new csv file name'
    dbms=csv
    replace;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc export data=sashelp.class(keep=Name Age) 
      dbms=csv
      outfile="INSERT_PATH\class.csv"
      replace
   ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 05:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483274#M71700</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-08-02T05:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483485#M71726</link>
      <description>&lt;P&gt;To add to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;if your variables have "nice" names that have a common base and suffix such as x1, x2, … xn you can use a list to indicate the variables such as x1 - x50&amp;nbsp; would get all of the variables x1 through x50. If you want all variables that start with common element then use x:&amp;nbsp; (no space before the colon)&amp;nbsp;. If the variables are adjacent in the data set you can use the two dash list delimiter&amp;nbsp;&amp;nbsp; thisvar -- thatvar. If thisvar is the 5th variable and thatvar is the 23rd variable in the data set then the list represents columns 5 through 23 with out having to list out all of the variables. You can specify multiple lists in a single KEEP statement or dataset option:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc export data=somefakedata (keep=Name abc1-abc25 freq: this--thatvar) 
      dbms=csv
      outfile="INSERT_PATH\class.csv"
      replace
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Aug 2018 17:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483485#M71726</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-02T17:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483495#M71727</link>
      <description>&lt;P&gt;Thanks guys it worked! =o)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I guess I was just referencing the wrong data set....~J&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 17:36:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483495#M71727</guid>
      <dc:creator>jenfumi</dc:creator>
      <dc:date>2018-08-02T17:36:38Z</dc:date>
    </item>
    <item>
      <title>Re: exporting subset of data from sas7bdat to csv</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483596#M71741</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;thanks for the tips. I will keep that in mind for the future. Unfortunately for my current situation, the selected variables had multiple prefixes with no more than 3 in common. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Aug 2018 21:18:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/exporting-subset-of-data-from-sas7bdat-to-csv/m-p/483596#M71741</guid>
      <dc:creator>jenfumi</dc:creator>
      <dc:date>2018-08-02T21:18:57Z</dc:date>
    </item>
  </channel>
</rss>

