<?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 Need to fill in missing sex info and count age in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776583#M31393</link>
    <description>&lt;P&gt;Hello, I need to fill in the missing sex info and the age info.&amp;nbsp; For age, I need to fill in with the age at each visit using the Adm_Date.&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;PatNo  Adm_Date AGE  Sex  &lt;BR /&gt;datalines;&lt;BR /&gt;101 12Jan2013 45.00   . &lt;BR /&gt;101 26Feb2016 .       F    &lt;BR /&gt;A11 07Mar2018 .       .   &lt;BR /&gt;251 05Nov/2015 66.00   M   &lt;BR /&gt;251 01Jan 2016 .       &lt;BR /&gt;251 23Jul2018 .       .       &lt;BR /&gt;251 09Jun2020 .        .        &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;Not sure what the best to these.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 19:07:52 GMT</pubDate>
    <dc:creator>Bluejags</dc:creator>
    <dc:date>2021-10-26T19:07:52Z</dc:date>
    <item>
      <title>Need to fill in missing sex info and count age</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776583#M31393</link>
      <description>&lt;P&gt;Hello, I need to fill in the missing sex info and the age info.&amp;nbsp; For age, I need to fill in with the age at each visit using the Adm_Date.&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;PatNo  Adm_Date AGE  Sex  &lt;BR /&gt;datalines;&lt;BR /&gt;101 12Jan2013 45.00   . &lt;BR /&gt;101 26Feb2016 .       F    &lt;BR /&gt;A11 07Mar2018 .       .   &lt;BR /&gt;251 05Nov/2015 66.00   M   &lt;BR /&gt;251 01Jan 2016 .       &lt;BR /&gt;251 23Jul2018 .       .       &lt;BR /&gt;251 09Jun2020 .        .        &lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;Not sure what the best to these.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 19:07:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776583#M31393</guid>
      <dc:creator>Bluejags</dc:creator>
      <dc:date>2021-10-26T19:07:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fill in missing sex info and count age</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776596#M31394</link>
      <description>&lt;P&gt;Sorry, in the last post I had not formatted the dates/data properly.&amp;nbsp; I was tried to use the RETAIN/COUNTER statement to get the Age from the second, third, and fourth adm_Dates.&amp;nbsp; I ended up getting the difference between second and first, third and second dates, and so on in a new column I labelled (Age_) with the RETAIN statement. As for assigning the Sex to the missing rows, I followed codes as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;@Ksharp ; the Sex column were filled correctly, but the first row for second patient (251) went missing form the final output, and instead, the second row of that patient was duplicated.&amp;nbsp; Wondering if this is because I am new to SAS, not correctly following the coding process.&lt;/P&gt;&lt;PRE&gt;PatNo  Adm_Date AGE  Sex  &lt;BR /&gt;101 12Jan2013 45.00   . &lt;BR /&gt;101 26Feb2016   .     F    &lt;BR /&gt;101 07Mar2018   .     .   &lt;BR /&gt;251 05Nov2015 66.00  M   &lt;BR /&gt;251 01Jan2016   .    .   &lt;BR /&gt;251 23Jul2018   .    .       &lt;BR /&gt;251 09Jun2020   .    .      &lt;/PRE&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 19:59:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776596#M31394</guid>
      <dc:creator>Bluejags</dc:creator>
      <dc:date>2021-10-26T19:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fill in missing sex info and count age</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776598#M31395</link>
      <description>&lt;P&gt;Note the differences in the 4th record with the date. Which data set is correct to be read in?&lt;/P&gt;
&lt;P&gt;This works fine for me, assuming the last data is correct.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Given what you've posted to me privately though, I suspect this also won't work as its not the issue you're looking to solve.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
informat PatNO $3. ADM_DATE date9. age 8. Sex $1.;
format adm_date date9.;
input PatNo  Adm_Date AGE  Sex ; 
cards;
101 12Jan2013 45.00   . 
101 26Feb2016   .     F    
101 07Mar2018   .     .   
251 05Nov2015 66.00  M   
251 01Jan2016   .    .   
251 23Jul2018   .    .       
251 09Jun2020   .    .   
;;;;
run;

*create master list;
proc sql;
create table want as
select patNO, adm_date, coalesce(age, max(age)) as age, coalesce(sex, max(sex)) as sex
from have
group by PATNO
order by 1, 2;
quit;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/404284"&gt;@Bluejags&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, in the last post I had not formatted the dates/data properly.&amp;nbsp; I was tried to use the RETAIN/COUNTER statement to get the Age from the second, third, and fourth adm_Dates.&amp;nbsp; I ended up getting the difference between second and first, third and second dates, and so on in a new column I labelled (Age_) with the RETAIN statement. As for assigning the Sex to the missing rows, I followed codes as suggested by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;and&amp;nbsp;@Ksharp ; the Sex column were filled correctly, but the first row for second patient (251) went missing form the final output, and instead, the second row of that patient was duplicated.&amp;nbsp; Wondering if this is because I am new to SAS, not correctly following the coding process.&lt;/P&gt;
&lt;PRE&gt;PatNo  Adm_Date AGE  Sex  &lt;BR /&gt;101 12Jan2013 45.00   . &lt;BR /&gt;101 26Feb2016   .     F    &lt;BR /&gt;101 07Mar2018   .     .   &lt;BR /&gt;251 05Nov2015 66.00  M   &lt;BR /&gt;251 01Jan2016   .    .   &lt;BR /&gt;251 23Jul2018   .    .       &lt;BR /&gt;251 09Jun2020   .    .      &lt;/PRE&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 20:12:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776598#M31395</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-26T20:12:36Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fill in missing sex info and count age</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776600#M31397</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;The latest dataset is the correct one&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;.&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Tue, 26 Oct 2021 20:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776600#M31397</guid>
      <dc:creator>Bluejags</dc:creator>
      <dc:date>2021-10-26T20:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need to fill in missing sex info and count age</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776602#M31399</link>
      <description>Then you should have an answer, see my post above.&lt;BR /&gt;</description>
      <pubDate>Tue, 26 Oct 2021 20:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-to-fill-in-missing-sex-info-and-count-age/m-p/776602#M31399</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-26T20:16:21Z</dc:date>
    </item>
  </channel>
</rss>

