<?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: Generate variable observations based on earliest date in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861806#M82560</link>
    <description>&lt;P&gt;Delete the rows with missing RACEETHNICITY and then run my code.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2023 18:19:49 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-03-01T18:19:49Z</dc:date>
    <item>
      <title>Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861785#M82555</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have the following data with these variables. For the same ID, the race/ethnicity is different, when it is supposed to be the same.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID_person&lt;/TD&gt;&lt;TD&gt;Admit Date&lt;/TD&gt;&lt;TD&gt;RaceEthnicity&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;1/03/2019&lt;/TD&gt;&lt;TD&gt;Non-Hispanic Black&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;2/06/2019&lt;/TD&gt;&lt;TD&gt;Non-Hispanic White&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3421&lt;/TD&gt;&lt;TD&gt;5/14/2020&lt;/TD&gt;&lt;TD&gt;Hispanic&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3421&lt;/TD&gt;&lt;TD&gt;3/21/2021&lt;/TD&gt;&lt;TD&gt;Non-Hispanic White&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4536&lt;/TD&gt;&lt;TD&gt;6/4/2020&lt;/TD&gt;&lt;TD&gt;Unknown&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To standardize the race/ethnicity information, I decided to make the race/ethnicity for each ID same as it was at the earliest admission date. How do I code for this?&lt;/P&gt;&lt;P&gt;I need the data to be like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID_person&lt;/TD&gt;&lt;TD&gt;Admit Date&lt;/TD&gt;&lt;TD&gt;RaceEthnicity&lt;/TD&gt;&lt;TD&gt;Raceeth_new&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;1/03/2019&lt;/TD&gt;&lt;TD&gt;Non-Hispanic Black&lt;/TD&gt;&lt;TD&gt;Non-Hispanic Black&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234&lt;/TD&gt;&lt;TD&gt;2/06/2019&lt;/TD&gt;&lt;TD&gt;Non-Hispanic White&lt;/TD&gt;&lt;TD&gt;Non-Hispanic Black&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3421&lt;/TD&gt;&lt;TD&gt;5/14/2020&lt;/TD&gt;&lt;TD&gt;Hispanic&lt;/TD&gt;&lt;TD&gt;Hispanic&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3421&lt;/TD&gt;&lt;TD&gt;3/21/2021&lt;/TD&gt;&lt;TD&gt;Non-Hispanic White&lt;/TD&gt;&lt;TD&gt;Hispanic&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4536&lt;/TD&gt;&lt;TD&gt;6/4/2020&lt;/TD&gt;&lt;TD&gt;Unknown&lt;/TD&gt;&lt;TD&gt;Unknown&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Wed, 01 Mar 2023 17:05:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861785#M82555</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2023-03-01T17:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861786#M82556</link>
      <description>&lt;P&gt;Assuming your data is sorted by ID_person and Admit_Date&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by id_person;
    retain raceeth_new;
    if first.id_person then raceeth_new=racethnicity;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Code is untested, as I cannot test the code against your screen captures (I can only test code against SAS data sets, please from now on provide SAS data sets as working SAS data step code, which you can type in yourself or follow &lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;these instructions&lt;/A&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 17:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861786#M82556</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-01T17:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861804#M82559</link>
      <description>&lt;P&gt;Hi, this worked great! But what if the earliest admission date has 'Unknown" Race and Ethnicity? How do I code to take the race/ethnicity for next admission date? Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:13:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861804#M82559</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2023-03-01T18:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861806#M82560</link>
      <description>&lt;P&gt;Delete the rows with missing RACEETHNICITY and then run my code.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:19:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861806#M82560</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-01T18:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861809#M82561</link>
      <description>&lt;P&gt;I cannot delete the rows as I have other variables which has important information. Any other way?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861809#M82561</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2023-03-01T18:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861810#M82562</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/342436"&gt;@Gayatrikunchay&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I cannot delete the rows as I have other variables which has important information. Any other way?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Delete the rows, run my code, obtain one row per ID, and then merge the results ReceEthnicity_new back into the original data set by ID, then no rows are missing.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:25:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861810#M82562</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-01T18:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Generate variable observations based on earliest date</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861819#M82568</link>
      <description>&lt;P&gt;This worked!! Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2023 18:57:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Generate-variable-observations-based-on-earliest-date/m-p/861819#M82568</guid>
      <dc:creator>Gayatrikunchay</dc:creator>
      <dc:date>2023-03-01T18:57:52Z</dc:date>
    </item>
  </channel>
</rss>

