<?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: Fill in rows for all dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588485#M168196</link>
    <description>&lt;P&gt;Is that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp; code what you are looking for ?&lt;/P&gt;</description>
    <pubDate>Fri, 13 Sep 2019 11:47:59 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2019-09-13T11:47:59Z</dc:date>
    <item>
      <title>Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588413#M168157</link>
      <description>&lt;P&gt;Hi. What is the protocol for follow-up questions if you have already marked an answer as a Solution?&lt;/P&gt;&lt;P&gt;Start another entry? Anyway, KSHARP posted a solution for me that I can't expand successfully on (add another column).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table of NAME1-Values responses by month/year. I need to fill in rows around them to&lt;/P&gt;&lt;P&gt;cover 11/2017 to the present month/year with a 0 value.&lt;/P&gt;&lt;P&gt;Unfortunately, I get all combinations of NAME and LABEL with the filled-in rows.&lt;/P&gt;&lt;P&gt;I only want the LABELS that go with NAME1 (see the bottom - LABEL13 should only be with NAME2).&lt;/P&gt;&lt;P&gt;I hope that is clear enough. LABEL1 just needs to be duplicated 22 times (i.e. NAME1-LABEL1 (22 date rows), NAME1-LABEL2 (22 date rows), NAME1-LABEL4 (22 rows) etc.). (Sometimes there is more than one LABEL column if that matters. They all just need&lt;/P&gt;&lt;P&gt;to be duplicated 22 times with their associated NAME....)&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;EXAMPLE FAILING OUTPUT:&lt;/P&gt;&lt;P&gt;name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; value&lt;BR /&gt;NAME1 LABEL1 11/2017 0&lt;BR /&gt;NAME1 LABEL1 12/2017 2&lt;BR /&gt;NAME1 LABEL1 01/2018 0&lt;BR /&gt;NAME1 LABEL1 02/2018 0&lt;BR /&gt;NAME1 LABEL1 03/2018 0&lt;BR /&gt;NAME1 LABEL1 04/2018 0&lt;BR /&gt;NAME1 LABEL1 05/2018 0&lt;BR /&gt;NAME1 LABEL1 06/2018 0&lt;BR /&gt;NAME1 LABEL1 07/2018 0&lt;BR /&gt;NAME1 LABEL1 08/2018 0&lt;BR /&gt;NAME1 LABEL1 09/2018 0&lt;BR /&gt;NAME1 LABEL1 10/2018 0&lt;BR /&gt;NAME1 LABEL1 11/2018 0&lt;BR /&gt;NAME1 LABEL1 12/2018 0&lt;BR /&gt;NAME1 LABEL1 01/2019 0&lt;BR /&gt;NAME1 LABEL1 02/2019 0&lt;BR /&gt;NAME1 LABEL1 03/2019 0&lt;BR /&gt;NAME1 LABEL1 04/2019 0&lt;BR /&gt;NAME1 LABEL1 05/2019 0&lt;BR /&gt;NAME1 LABEL1 06/2019 0&lt;BR /&gt;NAME1 LABEL1 07/2019 0&lt;BR /&gt;NAME1 LABEL1 08/2019 0&lt;BR /&gt;NAME1 LABEL1 09/2019 0&lt;BR /&gt;NAME1 &lt;FONT color="#FF0000"&gt;LABEL13&lt;/FONT&gt; 11/2017 0&lt;BR /&gt;NAME1 &lt;FONT color="#FF0000"&gt;LABEL13&lt;/FONT&gt; 12/2017 0&lt;BR /&gt;NAME1 &lt;FONT color="#FF0000"&gt;LABEL13&lt;/FONT&gt; 01/2018 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* I have added code to code from KSHARP */&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;input name $ label $ _date $ value;&lt;BR /&gt;date=input(cats('01/',_date),ddmmyy10.); /* CATS removes all blanks */&lt;BR /&gt;drop _:;&lt;BR /&gt;format date mmyys7.;&lt;BR /&gt;datalines;&lt;BR /&gt;NAME1 LABEL1 12/2017 2&lt;BR /&gt;NAME1 LABEL2 07/2018 1&lt;BR /&gt;NAME1 LABEL4 02/2019 3&lt;BR /&gt;NAME2 LABEL13 01/2018 3&lt;BR /&gt;NAME2 LABEL20 11/2018 4&lt;BR /&gt;NAME2 LABEL25 07/2019 1&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;data date1; /* this routine gives a column of dates */&lt;BR /&gt;do date='01nov2017'd to TODAY(); /* '01jul2019'd; */&lt;BR /&gt;if month(date) ne month then output;&lt;BR /&gt;month=month(date);&lt;BR /&gt;end;&lt;BR /&gt;drop month;&lt;BR /&gt;format date mmyys7.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql; /* JOIN date column to Name and value */&lt;BR /&gt;create table want as&lt;BR /&gt;select a.*,coalesce(b.value,0) as value&lt;BR /&gt;from (select * from&lt;BR /&gt;(select distinct name from have),(select distinct label from have), (select date from date1)&lt;BR /&gt;) as a left join have as b&lt;BR /&gt;on a.name=b.name AND a.label=b.label AND a.date=b.date ;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 01:23:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588413#M168157</guid>
      <dc:creator>crawfe</dc:creator>
      <dc:date>2019-09-13T01:23:33Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588448#M168184</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input name $ label $ _date $ value;
date=input(cats('01/',_date),ddmmyy10.); /* CATS removes all blanks */
drop _:;
format date mmyys7.;
datalines;
NAME1 LABEL1 12/2017 2
NAME1 LABEL2 07/2018 1
NAME1 LABEL4 02/2019 3
NAME2 LABEL13 01/2018 3
NAME2 LABEL20 11/2018 4
NAME2 LABEL25 07/2019 1
;

proc sort
  data=have (keep=name label)
  out=ref1
  nodupkey
;
by name label;
run;

data ref2;
set ref1;
date = input("2017-12-01",yymmdd10.);
do while (date le today());
  output;
  date = intnx('month',date,1);
end;
run;

data want;
merge
  have (in=a)
  ref2 (in=b)
;
by name label date;
if b;
if not a then value = 0;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 07:26:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588448#M168184</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-09-13T07:26:53Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588475#M168191</link>
      <description>&lt;P&gt;Not quite sure if that's what you want, but it seems that you could just change one line in the final SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql; /* JOIN date column to Name and value */
create table want as
select a.*,coalesce(b.value,0) as value
from (select * from
(select distinct name,label from have), (select date from date1) /* this is changed! */
) as a left join have as b
on a.name=b.name AND a.label=b.label AND a.date=b.date ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 11:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588475#M168191</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2019-09-13T11:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588485#M168196</link>
      <description>&lt;P&gt;Is that&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/76464"&gt;@s_lassen&lt;/a&gt;&amp;nbsp; code what you are looking for ?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 11:47:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588485#M168196</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-13T11:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588492#M168199</link>
      <description>&lt;P&gt;Yes! I don't get the subtle difference though. Two separate select statements vs&lt;/P&gt;&lt;P&gt;having them both in one, separated by a comma...&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 12:19:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588492#M168199</guid>
      <dc:creator>crawfe</dc:creator>
      <dc:date>2019-09-13T12:19:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588493#M168200</link>
      <description>&lt;P&gt;Can you post where is not right ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;name	label	date	value
NAME1	LABEL1	11/2017	0
NAME1	LABEL1	12/2017	2
NAME1	LABEL1	01/2018	0
NAME1	LABEL1	02/2018	0
NAME1	LABEL1	03/2018	0
NAME1	LABEL1	04/2018	0
NAME1	LABEL1	05/2018	0
NAME1	LABEL1	06/2018	0
NAME1	LABEL1	07/2018	0
NAME1	LABEL1	08/2018	0
NAME1	LABEL1	09/2018	0
NAME1	LABEL1	10/2018	0
NAME1	LABEL1	11/2018	0
NAME1	LABEL1	12/2018	0
NAME1	LABEL1	01/2019	0
NAME1	LABEL1	02/2019	0
NAME1	LABEL1	03/2019	0
NAME1	LABEL1	04/2019	0
NAME1	LABEL1	05/2019	0
NAME1	LABEL1	06/2019	0
NAME1	LABEL1	07/2019	0
NAME1	LABEL1	08/2019	0
NAME1	LABEL1	09/2019	0
NAME1	LABEL2	11/2017	0
NAME1	LABEL2	12/2017	0
NAME1	LABEL2	01/2018	0
NAME1	LABEL2	02/2018	0
NAME1	LABEL2	03/2018	0
NAME1	LABEL2	04/2018	0
NAME1	LABEL2	05/2018	0
NAME1	LABEL2	06/2018	0
NAME1	LABEL2	07/2018	1
NAME1	LABEL2	08/2018	0
NAME1	LABEL2	09/2018	0
NAME1	LABEL2	10/2018	0
NAME1	LABEL2	11/2018	0
NAME1	LABEL2	12/2018	0
NAME1	LABEL2	01/2019	0
NAME1	LABEL2	02/2019	0
NAME1	LABEL2	03/2019	0
NAME1	LABEL2	04/2019	0
NAME1	LABEL2	05/2019	0
NAME1	LABEL2	06/2019	0
NAME1	LABEL2	07/2019	0
NAME1	LABEL2	08/2019	0
NAME1	LABEL2	09/2019	0
NAME1	LABEL4	11/2017	0
NAME1	LABEL4	12/2017	0
NAME1	LABEL4	01/2018	0
NAME1	LABEL4	02/2018	0
NAME1	LABEL4	03/2018	0
NAME1	LABEL4	04/2018	0
NAME1	LABEL4	05/2018	0
NAME1	LABEL4	06/2018	0
NAME1	LABEL4	07/2018	0
NAME1	LABEL4	08/2018	0
NAME1	LABEL4	09/2018	0
NAME1	LABEL4	10/2018	0
NAME1	LABEL4	11/2018	0
NAME1	LABEL4	12/2018	0
NAME1	LABEL4	01/2019	0
NAME1	LABEL4	02/2019	3
NAME1	LABEL4	03/2019	0
NAME1	LABEL4	04/2019	0
NAME1	LABEL4	05/2019	0
NAME1	LABEL4	06/2019	0
NAME1	LABEL4	07/2019	0
NAME1	LABEL4	08/2019	0
NAME1	LABEL4	09/2019	0
NAME2	LABEL13	11/2017	0
NAME2	LABEL13	12/2017	0
NAME2	LABEL13	01/2018	3
NAME2	LABEL13	02/2018	0
NAME2	LABEL13	03/2018	0
NAME2	LABEL13	04/2018	0
NAME2	LABEL13	05/2018	0
NAME2	LABEL13	06/2018	0
NAME2	LABEL13	07/2018	0
NAME2	LABEL13	08/2018	0
NAME2	LABEL13	09/2018	0
NAME2	LABEL13	10/2018	0
NAME2	LABEL13	11/2018	0
NAME2	LABEL13	12/2018	0
NAME2	LABEL13	01/2019	0
NAME2	LABEL13	02/2019	0
NAME2	LABEL13	03/2019	0
NAME2	LABEL13	04/2019	0
NAME2	LABEL13	05/2019	0
NAME2	LABEL13	06/2019	0
NAME2	LABEL13	07/2019	0
NAME2	LABEL13	08/2019	0
NAME2	LABEL13	09/2019	0
NAME2	LABEL20	11/2017	0
NAME2	LABEL20	12/2017	0
NAME2	LABEL20	01/2018	0
NAME2	LABEL20	02/2018	0
NAME2	LABEL20	03/2018	0
NAME2	LABEL20	04/2018	0
NAME2	LABEL20	05/2018	0
NAME2	LABEL20	06/2018	0
NAME2	LABEL20	07/2018	0
NAME2	LABEL20	08/2018	0
NAME2	LABEL20	09/2018	0
NAME2	LABEL20	10/2018	0
NAME2	LABEL20	11/2018	4
NAME2	LABEL20	12/2018	0
NAME2	LABEL20	01/2019	0
NAME2	LABEL20	02/2019	0
NAME2	LABEL20	03/2019	0
NAME2	LABEL20	04/2019	0
NAME2	LABEL20	05/2019	0
NAME2	LABEL20	06/2019	0
NAME2	LABEL20	07/2019	0
NAME2	LABEL20	08/2019	0
NAME2	LABEL20	09/2019	0
NAME2	LABEL25	11/2017	0
NAME2	LABEL25	12/2017	0
NAME2	LABEL25	01/2018	0
NAME2	LABEL25	02/2018	0
NAME2	LABEL25	03/2018	0
NAME2	LABEL25	04/2018	0
NAME2	LABEL25	05/2018	0
NAME2	LABEL25	06/2018	0
NAME2	LABEL25	07/2018	0
NAME2	LABEL25	08/2018	0
NAME2	LABEL25	09/2018	0
NAME2	LABEL25	10/2018	0
NAME2	LABEL25	11/2018	0
NAME2	LABEL25	12/2018	0
NAME2	LABEL25	01/2019	0
NAME2	LABEL25	02/2019	0
NAME2	LABEL25	03/2019	0
NAME2	LABEL25	04/2019	0
NAME2	LABEL25	05/2019	0
NAME2	LABEL25	06/2019	0
NAME2	LABEL25	07/2019	1
NAME2	LABEL25	08/2019	0
NAME2	LABEL25	09/2019	0
&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2019 12:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588493#M168200</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-13T12:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588540#M168218</link>
      <description>&lt;P&gt;That is the correct output now. I was wondering about this code correction.&lt;/P&gt;&lt;P&gt;This Gave all the combinations of name-label:&lt;/P&gt;&lt;P&gt;(select distinct name from have),(select distinct label from have), (select date from date1)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;vs.&lt;/P&gt;&lt;P&gt;This Gave only desired combinations of name-label:&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;distinct&lt;/SPAN&gt; name&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;label&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; have&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;date&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;from&lt;/SPAN&gt; date1&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token comment"&gt;/* this is changed! */&lt;/SPAN&gt;
&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I was wondering how does SAS evaluate this differently?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2019 14:43:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588540#M168218</guid>
      <dc:creator>crawfe</dc:creator>
      <dc:date>2019-09-13T14:43:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in rows for all dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588719#M168297</link>
      <description>&lt;P&gt;The first SQL gave you all the combination of name ,label and date from the table .&lt;/P&gt;
&lt;P&gt;The second SQL gave you all the combination of&amp;nbsp; new variable (=cats(name,label) and date from the table .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can make some dummy data to test the difference between these two codes&amp;nbsp; by yourself .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Sep 2019 10:27:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fill-in-rows-for-all-dates/m-p/588719#M168297</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-09-14T10:27:32Z</dc:date>
    </item>
  </channel>
</rss>

