<?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: PROC APPEND Adding data when one column is gone in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776934#M247115</link>
    <description>&lt;P&gt;The DISTINCT keyword is unnecessary, as you only have the GROUP BY variable, a summary result, and a fixed value in the SELECT. The only possible effect is bad performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset created in the SQL does in no way match what's in the picture, so your question about the missing column does not make sense.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Oct 2021 10:34:05 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-28T10:34:05Z</dc:date>
    <item>
      <title>PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776919#M247111</link>
      <description>&lt;P&gt;I have a question about proc append. If I have such a table as below, which code I run every week and let's assume that next week I will not have any records, e.g. in 2021-12. Will it use proc append add data to me anyway and put 0 in the 2021-12 column. If not, what to use to avoid the situation that he will not give me another row of results because he will not find values in the previous month.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Gieorgie_1-1635412767812.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/65116iC807233407C43985/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Gieorgie_1-1635412767812.png" alt="Gieorgie_1-1635412767812.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;PROC SQL;   
   create table POLICY_VINTAGE_WEEKLY as
   select distinct 
   POLICY_VINTAGE
  ,count(NRB) as NUMBER_POLICY
  ,today() as Run_Date format=weeku.
   from PolisyEnd
   where POLIS ="A"
   group by 
   POLICY_VINTAGE
;
Quit;
proc append base=_work.policy_vintage_weekly data=policy_vintage_weekly;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 09:21:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776919#M247111</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-28T09:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776934#M247115</link>
      <description>&lt;P&gt;The DISTINCT keyword is unnecessary, as you only have the GROUP BY variable, a summary result, and a fixed value in the SELECT. The only possible effect is bad performance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The dataset created in the SQL does in no way match what's in the picture, so your question about the missing column does not make sense.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 10:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776934#M247115</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-28T10:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776962#M247118</link>
      <description>Thank you for your answer Kurt, this is a hypothetical assumption. I mean, when tomorrow I will run a same code and in the Policy_Vintage column with the date 2021-11 there will no longer be records, it will add POLICY_VINTAGE_WEEKLY a new position with the new Run_Date date. If so, whether in position 2021-01 will show 0 or empty cell ?</description>
      <pubDate>Thu, 28 Oct 2021 13:00:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776962#M247118</guid>
      <dc:creator>Gieorgie</dc:creator>
      <dc:date>2021-10-28T13:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776986#M247131</link>
      <description>&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;mentioned, your picture doesn't match the code.&amp;nbsp; Can you show your full code (after the SQL step, are you transposing the data to move your counts into columns)?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC APPEND will not create any records/values for you.&amp;nbsp; It simply reads records from the DATA= dataset and appends them to the BASE= dataset.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, PROC APPEND cannot add variables/columns to the base dataset.&amp;nbsp; So if you're you've got a base dataset with a column named NOV2021, and you use PROC APPEND to add records that have a new column DEC2021, the column won't be added. It will be ignored, or generate an error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Generally it's a bad idea to store data in a wide format with weeks/months in columns.&amp;nbsp; It's preferable to keep the data in the vertical format your SQL query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you describe more of your goal, and show more code, I think people will be able to make better suggestions.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 14:56:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/776986#M247131</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2021-10-28T14:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/777020#M247150</link>
      <description>&lt;P&gt;I don't deal in fairy tales. Please supply example data and the code you want to run against it, and the result you expect from that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if you ask íf something is possible, see Maxim 4.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 15:50:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/777020#M247150</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-28T15:50:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC APPEND Adding data when one column is gone</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/777129#M247198</link>
      <description>&lt;P&gt;Proc append by default will not append any data set with different structure than the base data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the FORCE option a data set missing a column or with "extra" columns may append but the extra columns won't be added. Or if the type of the variable is different than in base.&lt;/P&gt;
&lt;P&gt;A small example.&lt;/P&gt;
&lt;PRE&gt;data base;
   input x y z;
datalines;
1 2 3
;

data to_add;
  input x y q;
datalines;
44 55  66
;

/* default behavior no append and warning for 
   each difference in data set
*/
proc append base=base data=to_add;
run;

/*force option warning and variable q not added*/
proc append base=base data=to_add force;
run;

/* and if you end up with different data types*/

data to_add2;
   input x y z$;
datalines;
333 555 888
;

proc append base=base data=to_add2 force;
run;
&lt;/PRE&gt;
&lt;P&gt;If you have an empty data set to append no observations are added.&lt;/P&gt;
&lt;PRE&gt;data to_add3;
   set base (obs=0);
run;
proc append base=base data=to_add3 force;
run;
&lt;/PRE&gt;
&lt;P&gt;The above creates an empty data set from the structure of the base data as an example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your suspect variable name "2021-11" indicate that Append is not what you want. And if you want 0 in the rows without the 'new' value or previous columns you have lots of work.&lt;/P&gt;
&lt;P&gt;You probably should consider that this is a bad data structure because any analysis will require changing variable names in code in many places. You would like be better off with a data structure like&lt;/P&gt;
&lt;P&gt;Run_date (if this is even needed) Number_Policy Effective_date (which would be a date value with the year month) Value (or what ever the number 2188&amp;nbsp; 9078 etc means for each month).&lt;/P&gt;</description>
      <pubDate>Thu, 28 Oct 2021 21:57:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-APPEND-Adding-data-when-one-column-is-gone/m-p/777129#M247198</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-10-28T21:57:02Z</dc:date>
    </item>
  </channel>
</rss>

