<?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 a subset of dataset in new output file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38887#M7858</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of what you sent me, this is the code I was looking for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;data core;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; keep id var1-var6;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the PROC UNIVARIATE code (see one of the responses above), which gave me the means, also worked for what I needed. But I thank you for also sending me this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 01 Nov 2011 00:19:13 GMT</pubDate>
    <dc:creator>kvc</dc:creator>
    <dc:date>2011-11-01T00:19:13Z</dc:date>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38879#M7850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to create a subset of my dataset with just 6 variables. That is, I want to send these 6 variables, intact without performing any analyses on them, to an output file (I plan to merge these 6 variables with another group of mean-level variables that I created using the aggregate code that allowed me to send those mean-level variables to an output file). I found the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC UNIVARIATE DATA=SASdataset&amp;nbsp; options;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; options:PLOT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; VAR variable(s);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; BY variable(s);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OUTPUT OUT=SASdataset&amp;nbsp; keyword=variablename ... ;&lt;/P&gt;&lt;P&gt;Linear models&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, it's confusing to me and I'm not sure how to use it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 19:57:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38879#M7850</guid>
      <dc:creator>kvc</dc:creator>
      <dc:date>2011-10-31T19:57:41Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38880#M7851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to be a bit more specific regarding what you want the output file to contain.&amp;nbsp; Here is an example that might help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sex;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC UNIVARIATE DATA=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; VAR age height weight;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by sex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; OUTPUT OUT=want mean=mean_age mean_height mean_weight&lt;/P&gt;&lt;P&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; std=sd_age sd_height sd_weight;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 20:15:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38880#M7851</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-31T20:15:53Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38881#M7852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I tried your code but the output wasn't what I was looking for. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are about 1500 participants that have data in the cells for these six variables. If I were able to copy&amp;nbsp; the six variables with the data (not the means of the data), and&amp;nbsp; then paste them into a new SAS file, that would be what I am trying to do. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does that make sense? I just want a subset of the actual variables with their original data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38881#M7852</guid>
      <dc:creator>kvc</dc:creator>
      <dc:date>2011-10-31T23:11:43Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38882#M7853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can't you just merge the resulting file with your original data?&amp;nbsp; Conversely, proc univariate has an IDout option that will probably do what you want.&amp;nbsp; Some procs have a copy option that will also bring in other fields.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38882#M7853</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-31T23:17:10Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38883#M7854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know I'm not explaining this right. I'll try again. I am working with a very large dataset that includes individuals who are reporting on many different things. In this dataset are also variables about the schools these individuals attend. I am trying to extricate the school-level variables from the dataset so I can run some separate analyses on just the school level data. I don't want to merge these variables back into the dataset. They are already in the dataset. I want to take them out of the dataset and have them in a separate file. Does this make sense?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:28:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38883#M7854</guid>
      <dc:creator>kvc</dc:creator>
      <dc:date>2011-10-31T23:28:23Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38884#M7855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No! To me, that conflicts with what you've said and asked before.&amp;nbsp; It would help if you show a very simple example with, say, 3 people from each of two schools, and only one measure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would be helpful, in such an example, is what the data look like coming in and what you would want the resulting file to look like.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:32:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38884#M7855</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-31T23:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38885#M7856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What do you mean by subset? &lt;/P&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;I just want a subset of the actual variables with their original data.&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Usually a subset means a reduction in the number of OBSERVATIONS? &lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data seniors;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; where 65 &amp;lt;= age ;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But it appears that you are talking about a subset of the number of VARIABLES?&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data core;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep id var1-var6;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Either way there is no need to copy and paste anything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What do you mean by "with their original data"?&amp;nbsp; A subset by definition would be a copy of the original data.&lt;/P&gt;&lt;P&gt;Did you want to do some analysis?&amp;nbsp; Perhaps calculate some statistic on the data and combine it some way with the original data?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you want to calculate statistics across observations?&amp;nbsp; Such as a mean or a sum?&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table want as &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select id,var1,mean(var1) as mean_var1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; from have&lt;/P&gt;&lt;P&gt;&amp;nbsp; ;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you want to calculate a statistic across variables?&amp;nbsp; &lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code"&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; mean = mean(of var1-var6);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38885#M7856</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2011-10-31T23:40:10Z</dc:date>
    </item>
    <item>
      <title>Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38886#M7857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Okay, I just realized that above you did answer my question. I just didn't need the SDs, and I got confused by the output. I think I understand what I didn't before. So thank you for your help here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 23:54:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38886#M7857</guid>
      <dc:creator>kvc</dc:creator>
      <dc:date>2011-10-31T23:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a subset of dataset in new output file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38887#M7858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Of what you sent me, this is the code I was looking for:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE class="jive-code"&gt;data core;&lt;BR /&gt;&amp;nbsp; set have;&lt;BR /&gt;&amp;nbsp; keep id var1-var6;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the PROC UNIVARIATE code (see one of the responses above), which gave me the means, also worked for what I needed. But I thank you for also sending me this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 00:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-subset-of-dataset-in-new-output-file/m-p/38887#M7858</guid>
      <dc:creator>kvc</dc:creator>
      <dc:date>2011-11-01T00:19:13Z</dc:date>
    </item>
  </channel>
</rss>

