<?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: Add Partially Blank Observation to Dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559446#M10323</link>
    <description>&lt;P&gt;Hi Jane,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the IF-THEN statement by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;output;
if lastone then do;
  _n_=cum_soln;
  call missing(of _all_);
  additup=_n_;
  output;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I store the value of CUM_SOLN in the automatic variable _N_, which is not included in variable list _ALL_, so that the value for ADDITUP is still available after clearing the other variables (without needing a more specific variable list).&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2019 18:50:48 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-05-16T18:50:48Z</dc:date>
    <item>
      <title>Add Partially Blank Observation to Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559429#M10316</link>
      <description>&lt;P&gt;SAS Version 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is what I have...&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have1;
	input a b c;
datalines;
5 6 7
8 9 4
3 2 3
;
run;
data work.have2;
	input a b c;
datalines;
4 5 6
2 3 4
9 7 2
;
run;

proc sort data=work.have1; by a; run;
proc sort data=work.have2; by a; run;

data work.want;
	merge work.have1 work.have2 end=lastone;
	by a;
	Term=a*b*c;
	cum_soln+term;
	length cum_soln 8.;
	if lastone then additup=cum_soln;
run;

proc print data=work.want; title 'Add Observation for Total'; run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It compiles without errors in 9.4, but the output has the total on the same line as observation (6).&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Obs a b c Term cum_soln additup 
1 2 3 4 24 24 	. 
2 3 2 3 18 42	. 
3 4 5 6 120 162 . 
4 5 6 7 210 372 . 
5 8 9 4 288 660 . 
6 9 7 2 126 786 786 &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want an observation (7) that is completely blank with the exception of the final column where additup=786&lt;/P&gt;&lt;P&gt;The goal is to have outputs that cannot be misunderstood.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that the actual program has much more data, is within a macro, and&amp;nbsp;thus, does not include the first two data steps&lt;/P&gt;&lt;P&gt;creating datasets&amp;nbsp;work.have1 and work.have2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for helping.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yours,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 18:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559429#M10316</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-05-16T18:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Add Partially Blank Observation to Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559443#M10321</link>
      <description>&lt;P&gt;I believe this code will accomplish what you are looking for:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.want;
	merge work.have1 
		  work.have2 end=lastone;
	by a;
	Term=a*b*c;
	cum_soln+term;
	length cum_soln 8.;
	LENGTH additup 3;
	output;
	IF lastone THEN DO; 
		A = .;
		B=.;
		C=.;
		term=.;
		additup=cum_soln;
		output;
	END;
	DROP cum_soln;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 18:45:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559443#M10321</guid>
      <dc:creator>tsap</dc:creator>
      <dc:date>2019-05-16T18:45:18Z</dc:date>
    </item>
    <item>
      <title>Re: Add Partially Blank Observation to Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559446#M10323</link>
      <description>&lt;P&gt;Hi Jane,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Replace the IF-THEN statement by&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;output;
if lastone then do;
  _n_=cum_soln;
  call missing(of _all_);
  additup=_n_;
  output;
end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I store the value of CUM_SOLN in the automatic variable _N_, which is not included in variable list _ALL_, so that the value for ADDITUP is still available after clearing the other variables (without needing a more specific variable list).&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 18:50:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559446#M10323</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-05-16T18:50:48Z</dc:date>
    </item>
    <item>
      <title>Re: Add Partially Blank Observation to Dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559463#M10326</link>
      <description>&lt;PRE&gt;IF lastone THEN DO; 
		call missing (A,B,C,term);
		additup=cum_soln;
		output;
	END;
&lt;/PRE&gt;
&lt;P&gt;Call missing is one of the few data manipulation functions that will work on both character and numeric variables and all at the same time.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 19:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Add-Partially-Blank-Observation-to-Dataset/m-p/559463#M10326</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-16T19:33:48Z</dc:date>
    </item>
  </channel>
</rss>

