<?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: If missing append a dummy record in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46844#M9678</link>
    <description>SPR,&lt;BR /&gt;
 There could be more than one prod missing.</description>
    <pubDate>Fri, 08 Apr 2011 15:54:03 GMT</pubDate>
    <dc:creator>SASPhile</dc:creator>
    <dc:date>2011-04-08T15:54:03Z</dc:date>
    <item>
      <title>If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46842#M9676</link>
      <description>reg                     prod    A          B        C&lt;BR /&gt;
00                       A      20          25      30&lt;BR /&gt;
00                       B      20          25      30&lt;BR /&gt;
00                       C      20          25      30&lt;BR /&gt;
56                       A      40            .       35&lt;BR /&gt;
56                       C	   20            .       35&lt;BR /&gt;
&lt;BR /&gt;
The above data shows that for regions 00 and 56 there should ne three products A,B,C. But region 56 has product B missing.It has only A and C. also the data shows variables A B C (products) and their count in each region.&lt;BR /&gt;
&lt;BR /&gt;
Now since B is missing from region 56, how to add a dummy record with product B such that the data will be as shown below&lt;BR /&gt;
&lt;BR /&gt;
reg                  prod                    A          B       C&lt;BR /&gt;
00                     A                     20         25      30&lt;BR /&gt;
00                    B                      20          25      30&lt;BR /&gt;
00                   C                       20          25      30&lt;BR /&gt;
56                   A                      40           1       35&lt;BR /&gt;
56                   B                      40           1       35&lt;BR /&gt;
56                   C	              40           1       35</description>
      <pubDate>Fri, 08 Apr 2011 13:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46842#M9676</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-04-08T13:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46843#M9677</link>
      <description>Hello SASPhile,&lt;BR /&gt;
&lt;BR /&gt;
It is a solution. However, you do not specify if you are interested in case when 2 products have missing values or you have more then 3 products. Anyway this is it:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  input reg prod $ A B C;&lt;BR /&gt;
datalines;&lt;BR /&gt;
00 A 20 25 30&lt;BR /&gt;
00 B 20 25 30&lt;BR /&gt;
00 C 20 25 30&lt;BR /&gt;
56 A 40 . 35&lt;BR /&gt;
56 C 20 . 35&lt;BR /&gt;
run;&lt;BR /&gt;
data t;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  fa=0; fb=0; fc=0;&lt;BR /&gt;
  if A = . then do; A=1; fa=1; end;&lt;BR /&gt;
  if B = . then do; B=1; fb=1; end;&lt;BR /&gt;
  if C = . then do; C=1; fc=1; end;&lt;BR /&gt;
  where A=. or B=. or C=.;&lt;BR /&gt;
run;&lt;BR /&gt;
data t1;&lt;BR /&gt;
  set t;&lt;BR /&gt;
  if fa=1 then prod="A";&lt;BR /&gt;
  if fb=1 then prod="B"; &lt;BR /&gt;
  if fc=1 then prod="C"; &lt;BR /&gt;
  drop fa fb fc;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=t1 nodupkey;&lt;BR /&gt;
  by reg prod;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i t1;&lt;BR /&gt;
  if A = . then A=1;&lt;BR /&gt;
  if B = . then B=1;&lt;BR /&gt;
  if C = . then C=1;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=r;&lt;BR /&gt;
  by reg prod;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 08 Apr 2011 14:53:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46843#M9677</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-08T14:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46844#M9678</link>
      <description>SPR,&lt;BR /&gt;
 There could be more than one prod missing.</description>
      <pubDate>Fri, 08 Apr 2011 15:54:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46844#M9678</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-04-08T15:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46845#M9679</link>
      <description>And there will be 9 prods</description>
      <pubDate>Fri, 08 Apr 2011 15:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46845#M9679</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-04-08T15:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46846#M9680</link>
      <description>Hello, &lt;BR /&gt;
&lt;BR /&gt;
This is a second attempt:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data i;&lt;BR /&gt;
  input reg prod $ A B C D E;&lt;BR /&gt;
datalines;&lt;BR /&gt;
00 A 20 25 30 10 11 12&lt;BR /&gt;
00 B 20 25 30 60 70 80&lt;BR /&gt;
00 C 20 25 30 25 45 23&lt;BR /&gt;
00 D 20 25 30 56 12 15&lt;BR /&gt;
00 E 20 25 30 65 11 22&lt;BR /&gt;
56 A 11 .  35 .  .  .&lt;BR /&gt;
56 C 11 .  35 .  .  .&lt;BR /&gt;
run;&lt;BR /&gt;
proc SQL;&lt;BR /&gt;
  select COUNT(distinct NAME) into :n from SASHELP.VCOLUMN &lt;BR /&gt;
  where LIBNAME="WORK" and MEMNAME="I" and UPCASE(NAME) not in ("REG","PROD");&lt;BR /&gt;
  %let n=%TRIM(&amp;amp;n);&lt;BR /&gt;
  select distinct NAME into :n1-:n&amp;amp;n from SASHELP.VCOLUMN &lt;BR /&gt;
  where LIBNAME="WORK" and MEMNAME="I" and UPCASE(NAME) not in ("REG","PROD");&lt;BR /&gt;
quit;&lt;BR /&gt;
%put n=&amp;amp;n n1=&amp;amp;n1 n&amp;amp;n=&amp;amp;&amp;amp;n&amp;amp;n;&lt;BR /&gt;
/***/;&lt;BR /&gt;
%macro a;&lt;BR /&gt;
data t;&lt;BR /&gt;
  set i;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
  if &amp;amp;&amp;amp;n&amp;amp;i = . then do; &amp;amp;&amp;amp;n&amp;amp;i=1; prod="&amp;amp;&amp;amp;n&amp;amp;i"; output; end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
  if &amp;amp;&amp;amp;n1=.&lt;BR /&gt;
  %do i=2 %to &amp;amp;n;  &lt;BR /&gt;
    or &amp;amp;&amp;amp;n&amp;amp;i=.&lt;BR /&gt;
  %end;&lt;BR /&gt;
  ;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=t nodupkey;&lt;BR /&gt;
  by reg prod;&lt;BR /&gt;
run;&lt;BR /&gt;
data r;&lt;BR /&gt;
  set i t;&lt;BR /&gt;
  %do i=1 %to &amp;amp;n;&lt;BR /&gt;
  if &amp;amp;&amp;amp;n&amp;amp;i = . then do; &amp;amp;&amp;amp;n&amp;amp;i=1; end;&lt;BR /&gt;
  %end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=r;&lt;BR /&gt;
  by reg prod;&lt;BR /&gt;
run;&lt;BR /&gt;
%mend a;&lt;BR /&gt;
%a&lt;BR /&gt;
[/pre]&lt;BR /&gt;
SPR</description>
      <pubDate>Fri, 08 Apr 2011 18:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46846#M9680</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-08T18:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46847#M9681</link>
      <description>Hi,&lt;BR /&gt;
 Some of the products have space in them like "ORTHO TRI-CYCLEN LO".This is giving an error when &amp;amp;&amp;amp;n&amp;amp;i resolves to this value as this value is a column name.&lt;BR /&gt;
is there a turn around fir this&amp;gt;</description>
      <pubDate>Sat, 09 Apr 2011 14:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46847#M9681</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-04-09T14:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46848#M9682</link>
      <description>[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
input reg $ prod $ A B C;&lt;BR /&gt;
datalines;&lt;BR /&gt;
00 A 20 25 30&lt;BR /&gt;
00 B 20 25 30&lt;BR /&gt;
00 C 20 25 30&lt;BR /&gt;
56 A 40 . 35&lt;BR /&gt;
56 C 20 . 35&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc stdize data=temp missing=1 reponly out=want;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Mon, 11 Apr 2011 09:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46848#M9682</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-11T09:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: If missing append a dummy record</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46849#M9683</link>
      <description>thanks!</description>
      <pubDate>Wed, 13 Apr 2011 18:35:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-missing-append-a-dummy-record/m-p/46849#M9683</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2011-04-13T18:35:33Z</dc:date>
    </item>
  </channel>
</rss>

