<?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: Write column values from one observation to another in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945496#M370424</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/257733"&gt;@taishayla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks! I couldn't get this code to work, however.&amp;nbsp; Log says the ParticipantID variable is uninitialized and returns a dataset with no observations.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Make sure you know the NAMES of the variables in your dataset so that the code uses the right names.&lt;/P&gt;</description>
    <pubDate>Fri, 27 Sep 2024 18:36:26 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2024-09-27T18:36:26Z</dc:date>
    <item>
      <title>Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945345#M370389</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset which looks something like the example provided below. In this example, my desired output would keep only the first observation for each ParticipantID. However, I need the values for Nurse and Team to be put into this first observation (which is currently blank). So, for this example, the output for ParticipantID=1 should have StartDate=8/1/2024, EndDate=8/16/2024, EndReason=Unknown, Nurse = A, Team=1. Any suggestions?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="taishayla_0-1727367045461.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/100693i50BDE7ADF8AF6087/image-size/medium?v=v2&amp;amp;px=400" role="button" title="taishayla_0-1727367045461.png" alt="taishayla_0-1727367045461.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 16:13:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945345#M370389</guid>
      <dc:creator>taishayla</dc:creator>
      <dc:date>2024-09-26T16:13:22Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945346#M370390</link>
      <description>&lt;P&gt;So you want to group by&amp;nbsp;&lt;SPAN&gt;ParticipantID?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You want to result in only one observation per group?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do you want the values of STARTDATE ENDDATE ENDREASON from the first observation only and the&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;first non-empty value of NURSE TEAM?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If so then just merge two copies of the datasets.&amp;nbsp; One without those two variables and one with just those variables and only the non-missing observations.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have(drop=Nurse Team)
        have(keep=ParticipantID Nurse Team 
             where=(not missing(Nurse)))
  ;
  by participantID;
  if first.partcipantID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Could the first non empty NURSE be on a different observation than the first non empty TEAM?&amp;nbsp; IF so then merge three copies of the file instead of just two.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 16:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945346#M370390</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-26T16:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945356#M370393</link>
      <description>&lt;P&gt;Thank you so much for your response! Yes, I want to group by ParticipantID, with: only 1 observation per ID, Start/EndDates, EndReason from the first observation, and the first non-empty values of both Nurse and Team. It is possible that the first non-empty Nurse value can be within a different observation from that of the first non-empty Team Value. So for your proposed solution, it would be to merge copies of the same dataset? I want to make sure I understand this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 18:52:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945356#M370393</guid>
      <dc:creator>taishayla</dc:creator>
      <dc:date>2024-09-26T18:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945357#M370394</link>
      <description>&lt;P&gt;Sure. Just replicate the pattern for finding the first non missing value so each variable is found separately.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  merge have(drop=Nurse Team)
        have(keep=ParticipantID Nurse where=(not missing(Nurse)))
        have(keep=ParticipantID Team where=(not missing(Team)))
  ;
  by participantID;
  if first.partcipantID;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Try it on your data and see if you like the results.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Sep 2024 19:01:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945357#M370394</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-26T19:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945414#M370403</link>
      <description>&lt;P&gt;You'd better post your data as a DATA STEP code, nobody would like to type it for you if you need some help from others.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id start : mmddyy10. end : mmddyy10. reason $ nurse $ team;
cards;
1 8/1/2024 8/16/2024 unknown . .
1 8/25/2024 8/30/2024 . A 1
1 9/15/2024 9/24/2024 . B 1
;

proc sort data=have out=temp;
by id descending start;
run;
data want;
 update temp(obs=0) temp;
 by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2024 01:30:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945414#M370403</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-09-27T01:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945493#M370421</link>
      <description>&lt;P&gt;Thanks! I couldn't get this code to work, however.&amp;nbsp; Log says the ParticipantID variable is uninitialized and returns a dataset with no observations.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 18:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945493#M370421</guid>
      <dc:creator>taishayla</dc:creator>
      <dc:date>2024-09-27T18:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945495#M370423</link>
      <description>&lt;P&gt;Thank you, this worked!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 18:35:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945495#M370423</guid>
      <dc:creator>taishayla</dc:creator>
      <dc:date>2024-09-27T18:35:55Z</dc:date>
    </item>
    <item>
      <title>Re: Write column values from one observation to another</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945496#M370424</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/257733"&gt;@taishayla&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks! I couldn't get this code to work, however.&amp;nbsp; Log says the ParticipantID variable is uninitialized and returns a dataset with no observations.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Make sure you know the NAMES of the variables in your dataset so that the code uses the right names.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2024 18:36:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Write-column-values-from-one-observation-to-another/m-p/945496#M370424</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-09-27T18:36:26Z</dc:date>
    </item>
  </channel>
</rss>

