<?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 Base Programming for SAS 9 Exam in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493211#M129713</link>
    <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Sorry to be&amp;nbsp;vague with this inquiry.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I am working my way through the 27 main&amp;nbsp;objectives - and expanded objectives - for the exam.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Up until now, the specific intent of the stated exam objectives have been clear or became clear with some digging. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Random&amp;nbsp;examples: &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the DROP= and KEEP= data set options to specify columns to be processed and/or output"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the SAS/ACCESS EXCEL or PCFILES engine to read an .xlsx file OR use the SAS/ACCESS XLSX engine to read an .xlsx file"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;These,&amp;nbsp;and most other stated objectives&amp;nbsp;are fairly - if not crystal - clear. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;But I am stuck understanding precisely what is meant for this objective and expanded objective:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Accumulate sub-totals and totals using DATA step statements": &lt;FONT color="#ff0000"&gt;Do they mean &lt;/FONT&gt;&lt;FONT face="Arial" size="2"&gt;&lt;FONT color="#ff0000"&gt;aggregate &lt;STRONG&gt;functions&lt;/STRONG&gt; ? (sum, count, avg, etc.)&amp;nbsp;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the BY statement to aggregate by subgroups":&amp;nbsp;&lt;FONT color="#ff0000"&gt;Do they mean&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;First.variable Last.Variable&amp;nbsp;&amp;nbsp;?&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;At this point, I'm not asking to understand&amp;nbsp;anything specific programmatically about aggregate functions,&amp;nbsp;first.variable etc.&amp;nbsp;I'm just looking for&amp;nbsp;clarity about the intent of this particular&amp;nbsp;exam objective.&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;Greatly appreciate any insight&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;thanks&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Sep 2018 21:30:36 GMT</pubDate>
    <dc:creator>Rampsas1</dc:creator>
    <dc:date>2018-09-06T21:30:36Z</dc:date>
    <item>
      <title>Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493211#M129713</link>
      <description>&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Sorry to be&amp;nbsp;vague with this inquiry.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I am working my way through the 27 main&amp;nbsp;objectives - and expanded objectives - for the exam.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Up until now, the specific intent of the stated exam objectives have been clear or became clear with some digging. &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Random&amp;nbsp;examples: &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the DROP= and KEEP= data set options to specify columns to be processed and/or output"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the SAS/ACCESS EXCEL or PCFILES engine to read an .xlsx file OR use the SAS/ACCESS XLSX engine to read an .xlsx file"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;These,&amp;nbsp;and most other stated objectives&amp;nbsp;are fairly - if not crystal - clear. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;But I am stuck understanding precisely what is meant for this objective and expanded objective:&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Accumulate sub-totals and totals using DATA step statements": &lt;FONT color="#ff0000"&gt;Do they mean &lt;/FONT&gt;&lt;FONT face="Arial" size="2"&gt;&lt;FONT color="#ff0000"&gt;aggregate &lt;STRONG&gt;functions&lt;/STRONG&gt; ? (sum, count, avg, etc.)&amp;nbsp;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;"Use the BY statement to aggregate by subgroups":&amp;nbsp;&lt;FONT color="#ff0000"&gt;Do they mean&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;First.variable Last.Variable&amp;nbsp;&amp;nbsp;?&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;At this point, I'm not asking to understand&amp;nbsp;anything specific programmatically about aggregate functions,&amp;nbsp;first.variable etc.&amp;nbsp;I'm just looking for&amp;nbsp;clarity about the intent of this particular&amp;nbsp;exam objective.&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;Greatly appreciate any insight&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="2"&gt;thanks&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 21:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493211#M129713</guid>
      <dc:creator>Rampsas1</dc:creator>
      <dc:date>2018-09-06T21:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493215#M129716</link>
      <description>&lt;P&gt;&amp;nbsp;I suspect they're expecting you to be able to generate summaries using a data step as well as proc means.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, for the Class data set, create three extra rows, one that has the total or mean for males, one for females and one for overall.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So data set should be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Female records&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Female total&lt;/P&gt;
&lt;P&gt;Male records&lt;/P&gt;
&lt;P&gt;Male Total&lt;/P&gt;
&lt;P&gt;Grand Totals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This in particular isn't a useful example, but understanding how to carry variables values over rows and reset them is the key points that are used very often.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188614"&gt;@Rampsas1&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Hello,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Sorry to be&amp;nbsp;vague with this inquiry.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;I am working my way through the 27 main&amp;nbsp;objectives - and expanded objectives - for the exam.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Up until now, the specific intent of the stated exam objectives have been clear or became clear with some digging. &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;Random&amp;nbsp;examples: &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;"Use the DROP= and KEEP= data set options to specify columns to be processed and/or output"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;"Use the SAS/ACCESS EXCEL or PCFILES engine to read an .xlsx file OR use the SAS/ACCESS XLSX engine to read an .xlsx file"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;&lt;FONT color="#000000"&gt;&lt;FONT color="#000000"&gt;These,&amp;nbsp;and most other stated objectives&amp;nbsp;are fairly - if not crystal - clear. &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;But I am stuck understanding precisely what is meant for this objective and expanded objective:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;"Accumulate sub-totals and totals using DATA step statements": &lt;FONT color="#ff0000"&gt;Do they mean &lt;/FONT&gt;&lt;FONT face="Arial" size="2"&gt;&lt;FONT color="#ff0000"&gt;aggregate &lt;STRONG&gt;functions&lt;/STRONG&gt; ? (sum, count, avg, etc.)&amp;nbsp;&lt;/FONT&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;"Use the BY statement to aggregate by subgroups":&amp;nbsp;&lt;FONT color="#ff0000"&gt;Do they mean&amp;nbsp;&lt;FONT face="arial,helvetica,sans-serif" size="2"&gt;First.variable Last.Variable&amp;nbsp;&amp;nbsp;?&amp;nbsp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;At this point, I'm not asking to understand&amp;nbsp;anything specific programmatically about aggregate functions,&amp;nbsp;first.variable etc.&amp;nbsp;I'm just looking for&amp;nbsp;clarity about the intent of this particular&amp;nbsp;exam objective.&amp;nbsp;&amp;nbsp; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;Greatly appreciate any insight&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif" size="2" color="#000000"&gt;thanks&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Sep 2018 21:36:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493215#M129716</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-06T21:36:40Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493235#M129725</link>
      <description>&lt;P&gt;Hi:&lt;BR /&gt; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; is exactly correct. Accumulate and Aggregate have different meanings -- the objective uses accumulate. In this case, instead of aggregate functions like sum and mean, we do mean to use statements such as retain and first. and last. by variables to accumulate running totals and calculate totals for by groups. &lt;BR /&gt;&lt;BR /&gt;For example:&lt;BR /&gt;Start with this data:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;name qtr amt &lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 1&amp;nbsp; 15&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 3&amp;nbsp; 20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 4&amp;nbsp; 15&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 1&amp;nbsp; 10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 2&amp;nbsp; 10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 3&amp;nbsp; 10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 4&amp;nbsp; 10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt; &lt;BR /&gt;Generate this in a data step:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;name qtr amt running_tot&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 1&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 3&amp;nbsp;&amp;nbsp; 20&amp;nbsp;&amp;nbsp;&amp;nbsp; 35&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp; 4&amp;nbsp;&amp;nbsp; 15&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 1&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 2&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 3&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp; 4&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; 40&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt; &lt;BR /&gt;OR generate this in a data step:&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;name numqtr totamt&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;alan&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 50&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;barb&amp;nbsp;&amp;nbsp; 4 &amp;nbsp; &amp;nbsp;&amp;nbsp; 40&lt;/FONT&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;We show you these techniques in Programming 1 and Programming 2. You would use the RETAIN statement, the SUM statement and BY group processing.&lt;BR /&gt;&lt;BR /&gt;Cynthia&lt;/P&gt;</description>
      <pubDate>Fri, 07 Sep 2018 00:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/493235#M129725</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2018-09-07T00:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494129#M130161</link>
      <description>&lt;P&gt;Thanks so much Cynthia and Reeza.&lt;/P&gt;&lt;P&gt;RETAIN was the key word I was looking for.&lt;/P&gt;&lt;P&gt;I believe I&amp;nbsp;understand this,&amp;nbsp;but always appreciate feedback from the experts to know if there are better or different ways.&lt;/P&gt;&lt;P&gt;In my examples below, I'm calling "running_tot + amt" an "alias sum function with implicit retain" to attempt to&amp;nbsp;clarify&amp;nbsp;when we can 'opt out of' using retain explicitly. What&amp;nbsp;might&amp;nbsp;be the official name for this sum with implicit&amp;nbsp;retain? &amp;nbsp;(I also ran across examples&amp;nbsp;using 'if-then-do-else' and thought I'd apply those as well)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* answer 1a - using retain + sum function*/
data test_1a;
set test;
retain running_tot;
running_tot=sum(running_tot,amt);
run;
proc print data=test_1a;
run;

/* answer 1b - using "alias sum function with implicit retain" */
data test_1b;
set test;
running_tot + amt;
run;
proc print data=test_1b;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* assuming data might not be properly sorted*/
PROC SORT data=test;
by name;
run;

/* option 2a - using retain + sum function + by (first / last)*/
data test_2a (keep=name numqtr totamt);
set test;
put _all_;
BY name;
RETAIN numqtr totamt;
if first.name then totamt=amt;
else totamt=sum(totamt,amt);
if first.name then numqtr=1;
else numqtr=numqtr+1;
if last.name then output;
put _all_;
PUT ' ';
run;
proc print data=test_2a;
run;


/* answer 2b - same as 2a but using "if then do else" */
data test_2b (keep=name numqtr totamt);
set test;
put _all_;
BY name;
RETAIN numqtr totamt;
if first.name then do;
totamt=amt;
numqtr=1;
end;
else if first.name ne 1 then do;
totamt=sum(totamt,amt);
numqtr=numqtr+1;
end;
if last.name then output;
put _all_;
PUT ' ';
run;
proc print data=test_2b;
run;


/* option 2c - same as 2b (var order is different) but using "alias sum function with implicit retain" */
data test_2c (keep=name numqtr totamt);
set test;
put _all_;
BY name;
if first.name then do;
totamt=amt;
numqtr=1;
end;
else if first.name ne 1 then do;
totamt+amt;
numqtr+1;
end;
if last.name then output;
put _all_;
PUT ' ';
run;
proc print data=test_2c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Sep 2018 13:58:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494129#M130161</guid>
      <dc:creator>Rampsas1</dc:creator>
      <dc:date>2018-09-10T13:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494130#M130162</link>
      <description>and ... sorry for the all the "put _all_" in my examples but it REALLY helped me to understand the PDV behavior</description>
      <pubDate>Mon, 10 Sep 2018 14:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494130#M130162</guid>
      <dc:creator>Rampsas1</dc:creator>
      <dc:date>2018-09-10T14:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494141#M130167</link>
      <description>&lt;P&gt;You aren't using the SUM &lt;U&gt;&lt;STRONG&gt;function&lt;/STRONG&gt;&lt;/U&gt;, SUM(), you're using a SUM &lt;U&gt;&lt;STRONG&gt;s&lt;/STRONG&gt;&lt;STRONG&gt;tatement&lt;/STRONG&gt;&lt;/U&gt; which is different.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Sep 2018 14:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494141#M130167</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-10T14:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Base Programming for SAS 9 Exam</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494609#M130367</link>
      <description>&lt;P&gt;thanks for the clarification.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Sep 2018 18:59:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Base-Programming-for-SAS-9-Exam/m-p/494609#M130367</guid>
      <dc:creator>Rampsas1</dc:creator>
      <dc:date>2018-09-11T18:59:35Z</dc:date>
    </item>
  </channel>
</rss>

