<?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 Blanks on Last Column when Value Found in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478447#M71364</link>
    <description>&lt;P&gt;Remember to reset at boundaries (Cohort or such) as needed. I forgot about that in the code above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by cohort;

if first.cohort then call missing(retained_var);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 17:53:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-07-16T17:53:08Z</dc:date>
    <item>
      <title>Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478430#M71361</link>
      <description>&lt;P&gt;How can I convert table 1 to table 2?&amp;nbsp;&amp;nbsp;I’m trying to fill in the blanks on the last column only after a value is found.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table test (&lt;BR /&gt; id int, &lt;BR /&gt; cohort varchar(100), &lt;BR /&gt; term varchar(100), &lt;BR /&gt; class varchar(1)&lt;BR /&gt; );&lt;/P&gt;
&lt;P&gt;insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2016', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2015', 'S');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2014', 'S');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2013', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2012', 'S');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2011', 'A');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2010', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2009', '');&lt;/P&gt;
&lt;P&gt;create table test2 (&lt;BR /&gt; id int, &lt;BR /&gt; cohort varchar(100), &lt;BR /&gt; term varchar(100), &lt;BR /&gt; class varchar(1)&lt;BR /&gt; );&lt;/P&gt;
&lt;P&gt;insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2016', '');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2015', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2014', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2013', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2012', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2011', 'A');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2010', 'A');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2009', 'A');&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sort data=test2;&lt;BR /&gt; by id cohort term;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478430#M71361</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-07-16T17:23:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478439#M71362</link>
      <description>&lt;P&gt;RETAIN?&lt;/P&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;retain temp_class;
if not missing(class) then temp_class=class;
else class=temp_class;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478439#M71362</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-16T17:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478443#M71363</link>
      <description>&lt;P&gt;Thanks that worked.&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478443#M71363</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-07-16T17:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478447#M71364</link>
      <description>&lt;P&gt;Remember to reset at boundaries (Cohort or such) as needed. I forgot about that in the code above.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;by cohort;

if first.cohort then call missing(retained_var);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 17:53:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478447#M71364</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-16T17:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478458#M71365</link>
      <description>&lt;P&gt;I'm trying to add in an if condition to the else logic instead of generally copying the class down.&amp;nbsp; I think the value from the line&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else if student_classificationf in('A', 'M', 'D') then student_classification1 = student_classificationf; is saving in the retain so the other values are not set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data enr_ready_all_enrollment; set enr_ready_all_enrollment;&lt;BR /&gt; by person_uid cohort;&lt;BR /&gt; if first.cohort then student_classification_descf = '';&lt;BR /&gt; retain student_classification_descf;&lt;BR /&gt; if not missing(student_classification1) then student_classification_descf=student_classification1;&lt;BR /&gt; else do;&lt;BR /&gt; if student_classificationf in ('J', 'R', 'S', 'B', 'N', 'F') then student_classification1='N';&lt;BR /&gt; else if student_classificationf in('A', 'M', 'D') then student_classification1 = student_classificationf;&lt;BR /&gt; else if student_classification1 = student_classificationf;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 18:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478458#M71365</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-07-16T18:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478459#M71366</link>
      <description>&lt;P&gt;&lt;SPAN&gt;else if student_classification1 = student_classificationf;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This line looks incorrect?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 18:24:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478459#M71366</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-16T18:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: Fill in Blanks on Last Column when Value Found</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478462#M71367</link>
      <description>&lt;P&gt;This works&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; create table test (&lt;BR /&gt; id int, &lt;BR /&gt; cohort varchar(100), &lt;BR /&gt; term varchar(100), &lt;BR /&gt; class varchar(1)&lt;BR /&gt; );&lt;/P&gt;
&lt;P&gt;insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2016', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2015', 'M');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2014', 'S');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2013', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2012', 'S');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2011', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2010', '');&lt;BR /&gt; insert into test (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2009', '');&lt;/P&gt;
&lt;P&gt;create table test2 (&lt;BR /&gt; id int, &lt;BR /&gt; cohort varchar(100), &lt;BR /&gt; term varchar(100), &lt;BR /&gt; class varchar(1)&lt;BR /&gt; );&lt;/P&gt;
&lt;P&gt;insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2016', '');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2015', 'M');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2014', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2013', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2012', 'S');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2011', 'A');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2010', 'A');&lt;BR /&gt; insert into test2 (id, cohort, term, class) values (253303, 'Fall 2009', 'Fall 2009', 'A');&lt;/P&gt;
&lt;P&gt;quit;&lt;/P&gt;
&lt;P&gt;proc sort data=test2;&lt;BR /&gt; by id cohort term;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;/*fill in blanks for student classifications*/&lt;BR /&gt;proc sort data=test;&lt;BR /&gt; by id cohort descending term;&lt;BR /&gt;run;&lt;BR /&gt;data test3; set test;&lt;BR /&gt; by id cohort;&lt;BR /&gt; if first.cohort then temp_class = '';&lt;BR /&gt; retain temp_class;&lt;BR /&gt; if not missing(class) then temp_class=class;&lt;BR /&gt; else do;&lt;BR /&gt; if temp_class in ('J', 'R', 'S', 'B', 'N', 'F') then class='N';&lt;BR /&gt; else if temp_class in('A', 'M', 'D') then class = temp_class;&lt;BR /&gt; else class = temp_class;&lt;BR /&gt; end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 18:35:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Fill-in-Blanks-on-Last-Column-when-Value-Found/m-p/478462#M71367</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-07-16T18:35:18Z</dc:date>
    </item>
  </channel>
</rss>

