<?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 keep appending data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391171#M93916</link>
    <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I modify the code as you comment below: It works and almost there as oputput of skewdata includes observation 13 to 22 which looks redundant. I'll try to fix it and really appreciate your support!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE work.query AS
   SELECT j , i , X , Y FROM MYSECOND.SPC; 
   /*WHERE J=&amp;amp;j AND Y=0;*/
   RUN;
   QUIT;

   /*PROC DATASETS NOLIST NODETAILS;
   CONTENTS DATA=work.query OUT=WORK.details;
   RUN;  

   PROC PRINT DATA=WORK.details;
   RUN;*/    /*No need to print work.detail*/
   ods noproctitle;
   ods graphics / imagemap=on;

   proc means data=work.query chartype NWAY mean std min max n vardef=df skew SKEWNESS KURT KURTOSIS;
	var X;
	output out=work.skewtemp skew=Distskew KURT=DISKURT ;where (j between 0 and 10) and Y=0;       class J;
	
   run;
   data skewdata;
   set skewtemp;
   /*MODIFY skewdata;*/
   SKEWSQUARE=Distskew*Distskew;
   Excess_Kurt=DISKURT+3;
   /*output;*/
   run;   /*How to "amend" the file skewdata?*/
   proc append base=work.skewdata data=work.skewtemp force;

   run;

   proc print data=work.skewdata;
   run;

   run;
   ods graphics / reset imagemap;

   /*--SGPLOT proc statement--*/
   proc sgplot data=WORK.QUERY;
	/*--Histogram settings--*/
	histogram X /;

	/*--Vertical or Response Axis--*/
	yaxis grid;
   run;

   ods graphics / reset;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Aug 2017 01:20:27 GMT</pubDate>
    <dc:creator>Michaelcwang2</dc:creator>
    <dc:date>2017-08-28T01:20:27Z</dc:date>
    <item>
      <title>How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390857#M93816</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;I'm trying to append each calculated descriptive statistics in an iteration to a dataset. My coding is as below:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%MACRO SPCDIST;  /*Macro file is needed for repetitive SQL statement*/
%do j=1 %to 10;
   PROC SQL;
   CREATE TABLE work.query AS
   SELECT j , i , X , Y FROM MYSECOND.SPC 
   WHERE J=&amp;amp;j AND Y=0;
   RUN;
   QUIT;

   /*PROC DATASETS NOLIST NODETAILS;
   CONTENTS DATA=work.query OUT=WORK.details;
   RUN;  

   PROC PRINT DATA=WORK.details;
   RUN;*/    /*No need to print work.detail*/
   ods noproctitle;
   ods graphics / imagemap=on;

   proc means data=work.query chartype mean std min max n vardef=df skew SKEWNESS KURT KURTOSIS;
	var X;
	output out=work.skewtemp skew=Distskew KURT=DISKURT;
	
   run;
   data skewdata;
   set skewtemp;
   /*MODIFY skewdata ;
   /*SKEWSQUARE=Distskew*Distskew;*/
   /*output;*/
   run;   /*How to "amend" the file skewdata?*/
   proc append base=work.skewdata data=work.skewtemp force;

   run;

   proc print data=work.skewdata;
   run;

   run;
   ods graphics / reset imagemap;

   /*--SGPLOT proc statement--*/
   proc sgplot data=WORK.QUERY;
	/*--Histogram settings--*/
	histogram X /;

	/*--Vertical or Response Axis--*/
	yaxis grid;
   run;

   ods graphics / reset;
%end;
%MEND;
%SPCDIST;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I expect to have 10 observations recorded in the work.skewdata dataset but there is always two items for each iteration, would somebody help to clarify where went wrong and how to solve.&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 09:20:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390857#M93816</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2017-08-25T09:20:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390860#M93819</link>
      <description>&lt;P&gt;This part&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   data skewdata;
   set skewtemp;
   /*MODIFY skewdata ;
   /*SKEWSQUARE=Distskew*Distskew;*/
   /*output;*/
   run;   /*How to "amend" the file skewdata?*/
   proc append base=work.skewdata data=work.skewtemp force;

   run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;creates skewdata once with the contents of skewtemp, and then appends skewtemp to it, so you get twice the contents of skewtemp.&lt;/P&gt;
&lt;P&gt;Since skewdata is initialized by the first of the two datasteps in each iteration, only the doubled results of the last iteration will end up in skewdata.&lt;/P&gt;
&lt;P&gt;Initialize skewdata once before the iterations (or remove it altogether), and only keep the proc append step.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 09:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390860#M93819</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-25T09:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390875#M93823</link>
      <description>&lt;P&gt;How about extracting all of the data from the database in one PROC SQL extract, and then doing PROC MEANS and PROC SGPLOT with a BY statement, and then you don't need all this looping and you don't need PROC APPEND either.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 11:01:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390875#M93823</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2017-08-25T11:01:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390938#M93841</link>
      <description>&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;  &lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;means&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;query chartype NWAY &lt;SPAN class="token function"&gt;mean&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;std&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;min&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;max&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;n&lt;/SPAN&gt; vardef&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;df skew &lt;SPAN class="token function"&gt;SKEWNESS&lt;/SPAN&gt; KURT &lt;SPAN class="token function"&gt;KURTOSIS&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;BR /&gt;&lt;/SPAN&gt;       where (j between 0 and 10) and Y=0;&lt;BR /&gt;       class J;
	&lt;SPAN class="token keyword"&gt;var&lt;/SPAN&gt; X&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	output out&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;work&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;skewtemp skew&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;Distskew KURT&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;DISKURT&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
	
   &lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need a macro here. See the code above and note the following changes:&lt;/P&gt;
&lt;P&gt;NWAY&lt;/P&gt;
&lt;P&gt;WHERE&lt;/P&gt;
&lt;P&gt;CLASS&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 15:18:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/390938#M93841</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-25T15:18:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391037#M93862</link>
      <description>I'll check and update, thank you.</description>
      <pubDate>Sat, 26 Aug 2017 00:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391037#M93862</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2017-08-26T00:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391038#M93863</link>
      <description>Thank you for your comment.</description>
      <pubDate>Sat, 26 Aug 2017 00:11:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391038#M93863</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2017-08-26T00:11:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391039#M93864</link>
      <description>Thank you and I'll study and see how it works.</description>
      <pubDate>Sat, 26 Aug 2017 00:12:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391039#M93864</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2017-08-26T00:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep appending data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391171#M93916</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;I modify the code as you comment below: It works and almost there as oputput of skewdata includes observation 13 to 22 which looks redundant. I'll try to fix it and really appreciate your support!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
   CREATE TABLE work.query AS
   SELECT j , i , X , Y FROM MYSECOND.SPC; 
   /*WHERE J=&amp;amp;j AND Y=0;*/
   RUN;
   QUIT;

   /*PROC DATASETS NOLIST NODETAILS;
   CONTENTS DATA=work.query OUT=WORK.details;
   RUN;  

   PROC PRINT DATA=WORK.details;
   RUN;*/    /*No need to print work.detail*/
   ods noproctitle;
   ods graphics / imagemap=on;

   proc means data=work.query chartype NWAY mean std min max n vardef=df skew SKEWNESS KURT KURTOSIS;
	var X;
	output out=work.skewtemp skew=Distskew KURT=DISKURT ;where (j between 0 and 10) and Y=0;       class J;
	
   run;
   data skewdata;
   set skewtemp;
   /*MODIFY skewdata;*/
   SKEWSQUARE=Distskew*Distskew;
   Excess_Kurt=DISKURT+3;
   /*output;*/
   run;   /*How to "amend" the file skewdata?*/
   proc append base=work.skewdata data=work.skewtemp force;

   run;

   proc print data=work.skewdata;
   run;

   run;
   ods graphics / reset imagemap;

   /*--SGPLOT proc statement--*/
   proc sgplot data=WORK.QUERY;
	/*--Histogram settings--*/
	histogram X /;

	/*--Vertical or Response Axis--*/
	yaxis grid;
   run;

   ods graphics / reset;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Aug 2017 01:20:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-appending-data/m-p/391171#M93916</guid>
      <dc:creator>Michaelcwang2</dc:creator>
      <dc:date>2017-08-28T01:20:27Z</dc:date>
    </item>
  </channel>
</rss>

