<?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 append data to an empty dataset using Data step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327444#M73052</link>
    <description>&lt;P&gt;You can use next skilton code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _out.WSTHIP;
   set _out.WSTHIP end=eof;&lt;BR /&gt;   output;&lt;BR /&gt;   if eof then do;&lt;BR /&gt;      .... enter here your code to assign new obs values...&lt;BR /&gt;      output;&lt;BR /&gt;   end;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 25 Jan 2017 16:45:17 GMT</pubDate>
    <dc:creator>Shmuel</dc:creator>
    <dc:date>2017-01-25T16:45:17Z</dc:date>
    <item>
      <title>How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327437#M73047</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;What I am trying to do is use an empty dataset as a "frame" (to set the variable order and lengths) and then append observations to that dataset with hardcoded data (using &amp;lt;variable&amp;gt;=&amp;lt;value&amp;gt; and output statements). &amp;nbsp;However, when I set the empty dataset and then try to add the variable and output statements, the resulting dataset always still has 0 observations. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;Here is some example code, in which the "_out.WSTHP" is the original empty dataset (0 observations, but contains all of the variables that are described below) and I am trying to add an observation containing the subsequent data. &amp;nbsp;I would have thought the hardcoded lines and output statement would create an observation, but the resulting dataset is still empty.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _out.WSTHIP;
   set _out.WSTHIP;
   __StudyOID="dummy";
   __MetaDataVersionOID="1.3";
   __SubjectKey="dummy-102";
   __StudyEventOID="e_fu10y";
   __StudyEventRepeatKey="001";
   __FormOID="f_metabpar";
   __FormRepeatKey="001";
   __ItemGroupOID="g_wsthip";
   __ItemGroupRepeatKey="001";
   __LocationOID="Center.Admin";
   __UserOID="User.034";
   HIP=201;
   WSTHIP=1;
   WAIST=201;                           
   output;
run;   &lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:34:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327437#M73047</guid>
      <dc:creator>Phil0917</dc:creator>
      <dc:date>2017-01-25T16:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327440#M73050</link>
      <description>&lt;P&gt;As it stands, the SET statement ends the DATA step because there are no observations to read.&amp;nbsp; Yet you need the SET statement within the DATA step to define the variables properly.&amp;nbsp; The solution is to keep the SET statement within the DATA step, yet avoid executing it.&amp;nbsp; For example, change it to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if 5=4 then set _out.WSTHIP;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327440#M73050</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-25T16:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327442#M73051</link>
      <description>&lt;P&gt;Yes, thats normal. &amp;nbsp;There are no obs being read, so nothing happens in the datastep. &amp;nbsp;Either create a datastep with your one record, then append or set that with your template, or you could use proc sql; insert into out.wthip __studyoid="abc"...; quit;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:41:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327442#M73051</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-25T16:41:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327444#M73052</link>
      <description>&lt;P&gt;You can use next skilton code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _out.WSTHIP;
   set _out.WSTHIP end=eof;&lt;BR /&gt;   output;&lt;BR /&gt;   if eof then do;&lt;BR /&gt;      .... enter here your code to assign new obs values...&lt;BR /&gt;      output;&lt;BR /&gt;   end;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327444#M73052</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-01-25T16:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327448#M73054</link>
      <description>&lt;P&gt;Thanks for the suggestion! &amp;nbsp;That did the trick!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327448#M73054</guid>
      <dc:creator>Phil0917</dc:creator>
      <dc:date>2017-01-25T16:58:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to append data to an empty dataset using Data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327450#M73055</link>
      <description>&lt;P&gt;Thanks for the suggestion! &amp;nbsp;I actually saw this method somewhere and tried it, but it still generated a 0 observation dataset. &amp;nbsp;I did get another suggestion in this thread that worked, but thanks anyway!!&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 16:59:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-append-data-to-an-empty-dataset-using-Data-step/m-p/327450#M73055</guid>
      <dc:creator>Phil0917</dc:creator>
      <dc:date>2017-01-25T16:59:58Z</dc:date>
    </item>
  </channel>
</rss>

