<?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: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824881#M325803</link>
    <description>&lt;PRE&gt;data have;
input (timestamp    client    age    gender    PCLscore  CDRISCscore) ( $);
cards;
4/08/22          xx        49     female         57                 15
4/14/22          xx        49     female         52                 17
5/12/22          xy        47     female         51                 31
5/02/22          zz        46     male            51                 27
5/13/22          zz        46     male            46                 24
;

data have;
 set have;
 by client;
 if first.client and not last.client then call missing(timestamp,PCLscore,CDRISCscore);
run;

proc sql noprint;
select max(n) into :n from
(select count(*) as n from have group by client,age,gender);
quit;

proc summary data=have nway;
class client age gender;
output out=want(drop=_:) idgroup(out[&amp;amp;n.] (timestamp PCLscore CDRISCscore)=);
run;
 &lt;/PRE&gt;</description>
    <pubDate>Fri, 22 Jul 2022 13:16:05 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2022-07-22T13:16:05Z</dc:date>
    <item>
      <title>Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824740#M325722</link>
      <description>&lt;P&gt;I am taking a long dataset (repeated measures) some have 2 timepoints of data - some do not. When I use the following code to transpose the variables of interest to a wide dataset something his happening that is not transcribing values within a record. Whenever the observation has a record for time1 and time 2 - the first (time1) is entered as missing when there is a value in existence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;dataset I have&lt;/P&gt;&lt;P&gt;timestamp&amp;nbsp; &amp;nbsp; client&amp;nbsp; &amp;nbsp; age&amp;nbsp; &amp;nbsp; gender&amp;nbsp; &amp;nbsp; PCLscore&amp;nbsp; CDRISCscore&lt;/P&gt;&lt;P&gt;4/08/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 49&amp;nbsp; &amp;nbsp; &amp;nbsp;female&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;57&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;15&lt;/P&gt;&lt;P&gt;4/14/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 49&amp;nbsp; &amp;nbsp; &amp;nbsp;female&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;52&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17&lt;/P&gt;&lt;P&gt;5/12/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; xy&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 47&amp;nbsp; &amp;nbsp; &amp;nbsp;female&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;51&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;31&lt;/P&gt;&lt;P&gt;5/02/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&amp;nbsp; &amp;nbsp; &amp;nbsp;male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 51&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;27&lt;/P&gt;&lt;P&gt;5/13/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; zz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&amp;nbsp; &amp;nbsp; &amp;nbsp;male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;what I get;&lt;/P&gt;&lt;P&gt;client&amp;nbsp; &amp;nbsp;age&amp;nbsp; &amp;nbsp;gender&amp;nbsp; &amp;nbsp; timestamp1&amp;nbsp; timestamp2 PCLscore1&amp;nbsp; PCLscore2 CDRISCscore1&amp;nbsp; &amp;nbsp; CDRISCscore3&lt;/P&gt;&lt;P&gt;xx&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 49&amp;nbsp; &amp;nbsp; &amp;nbsp;female&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/14/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 52&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;17&lt;/P&gt;&lt;P&gt;xy&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 47&amp;nbsp; &amp;nbsp; &amp;nbsp;female&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5/12/ 22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;51&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 31&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;zz&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 46&amp;nbsp; &amp;nbsp; &amp;nbsp;male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/13/22&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;46&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current code;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;DATA eHome12_Match_&amp;amp;V ;&lt;BR /&gt;SET eHome11_Match_&amp;amp;V ;&lt;BR /&gt;BY client ;&lt;/P&gt;&lt;P&gt;KEEP client age gender timestamp1-timestamp2 PCL_Rscore1-PCL_Rscore2 CDRISC_Rscore1-CDRISC_Rscore2&lt;BR /&gt;PCS1-PCS2 MCS1-MCS2;&lt;BR /&gt;RETAIN client age gender ;&lt;/P&gt;&lt;P&gt;ARRAY adate(1:2) timestamp1-timestamp2;&lt;BR /&gt;ARRAY apcs(1:2) PCS1-PCS2;&lt;BR /&gt;ARRAY amcs(1:2) MCS1-MCS2;&lt;BR /&gt;ARRAY acdrisc(1:2) CDRISC_Rscore1-CDRISC_Rscore2;&lt;BR /&gt;ARRAY apcl(1:2) PCL_Rscore1-PCL_Rscore2;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;IF first.client THEN&lt;BR /&gt;DO;&lt;BR /&gt;DO i = 1 to 2 ;&lt;BR /&gt;adate( i ) = . ;&lt;BR /&gt;acdrisc( i ) = . ;&lt;BR /&gt;apcs( i ) = .;&lt;BR /&gt;amcs( i ) = . ;&lt;BR /&gt;apcl( i ) = . ;&lt;BR /&gt;END;&lt;BR /&gt;END;&lt;/P&gt;&lt;P&gt;adate( time ) = timestamp ;&lt;BR /&gt;acdrisc( time ) = CDRISC_RScore ;&lt;BR /&gt;aPCL( time ) = PCL_RScore ;&lt;BR /&gt;aPCS( time ) = PCS ;&lt;BR /&gt;aMCS( time ) = MCS ;&lt;/P&gt;&lt;P&gt;IF last.client THEN OUTPUT ;&lt;/P&gt;&lt;P&gt;format timestamp1-timestamp2 mmddyy10.;&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 18:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824740#M325722</guid>
      <dc:creator>lberghammer</dc:creator>
      <dc:date>2022-07-21T18:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824745#M325727</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/267470"&gt;@lberghammer&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Whenever the observation has a record for time1 and time 2 - the first (time1) is entered as missing when there is a value in existence.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's because you successfully populate the first element of the arrays of interest when you encounter the first record.&amp;nbsp; But, because you do not retain those values, they are reset to missing whenever a second record is encountered, i.e. before data for that client is output.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I don't believe the code you present produced the output you show.&amp;nbsp; That's because you use the TIME variable as an index of the arrays.&amp;nbsp; Yet there is no time variable generated in your code, or shown in your input dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some simpler code (untested in the absence of sample data in a working data step):&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA eHome12_Match_&amp;amp;V ;
  do i=1 by 1 until (last.client);
    SET eHome11_Match_&amp;amp;V ;
    by client;

    ARRAY adate(1:2) timestamp1-timestamp2;
    ARRAY apcs(1:2) PCS1-PCS2;
    ARRAY amcs(1:2) MCS1-MCS2;
    ARRAY acdrisc(1:2) CDRISC_Rscore1-CDRISC_Rscore2;
    ARRAY apcl(1:2) PCL_Rscore1-PCL_Rscore2;

    adate{i}=timestamp;
    acdrisc(i) = CDRISC_RScore ;
    aPCL(i) = PCL_RScore ;
    aPCS(i) = PCS ;
    aMCS(i) = MCS ;
  end;
  KEEP client age gender timestamp1--pcl_rscore2 ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The main idea here is that all obs for a given client are read in during a single iteration of the data step&amp;nbsp; (i.e. the SET statement is inside a do ... until group).&amp;nbsp; &amp;nbsp;So no retains are needed to overcome the problem I mentioned above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BUT ... this program assumes you will &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;never&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt; have more than 2 obs per client.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 18:49:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824745#M325727</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-07-21T18:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824746#M325728</link>
      <description>&lt;P&gt;You need to Retain all of the variables ending in 1 so they have values for the second record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you expect to do with this "wide" data set that can't be done with the existing data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 18:51:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824746#M325728</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-07-21T18:51:42Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824760#M325736</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;BUT ... this program assumes you will&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;never&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;have more than 2 obs per client.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;It will just output multiple observations for those CLIENT values.&amp;nbsp; So if there are 3 or 4 observations it will write 2 observations. If there are 5 or 6 then it will write 3 observations, etc.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 19:37:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824760#M325736</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-21T19:37:58Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824779#M325751</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;quoted my comment&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;BUT ... this program assumes you will&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;never&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;have more than 2 obs per client.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and replied&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;It will just output multiple observations for those CLIENT values.&amp;nbsp; So if there are 3 or 4 observations it will write 2 observations. If there are 5 or 6 then it will write 3 observations, etc.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;
&lt;P&gt;If there are any clients with more than two obs this code will not write the last two observations for that client.&amp;nbsp; It won't write any.&amp;nbsp; When it encounters such a client, it will stop with an error message&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Array subscript out of range at line xxx column yyy.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting data set will be partial - it will contain the desired results for all clients preceding the first client with more than 2 obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2022 20:36:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824779#M325751</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2022-07-21T20:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824786#M325758</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;quoted my comment&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;BUT ... this program assumes you will&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;never&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;have more than 2 obs per client.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;and replied&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;It will just output multiple observations for those CLIENT values.&amp;nbsp; So if there are 3 or 4 observations it will write 2 observations. If there are 5 or 6 then it will write 3 observations, etc.&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;HR /&gt;
&lt;P&gt;If there are any clients with more than two obs this code will not write the last two observations for that client.&amp;nbsp; It won't write any.&amp;nbsp; When it encounters such a client, it will stop with an error message&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ERROR: Array subscript out of range at line xxx column yyy.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The resulting data set will be partial - it will contain the desired results for all clients preceding the first client with more than 2 obs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Did not realize they did not code the DO loop properly.&lt;/P&gt;
&lt;P&gt;If you don't want it to fail when there are too many observations set the upperbound.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  do i=1 to dim(adate) until (last.client);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or if you actually used non-standard upper and lower bounds use&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; do i=lbound(adate) to ubound(adate) until (last.client);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Jul 2022 21:07:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824786#M325758</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-21T21:07:00Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824881#M325803</link>
      <description>&lt;PRE&gt;data have;
input (timestamp    client    age    gender    PCLscore  CDRISCscore) ( $);
cards;
4/08/22          xx        49     female         57                 15
4/14/22          xx        49     female         52                 17
5/12/22          xy        47     female         51                 31
5/02/22          zz        46     male            51                 27
5/13/22          zz        46     male            46                 24
;

data have;
 set have;
 by client;
 if first.client and not last.client then call missing(timestamp,PCLscore,CDRISCscore);
run;

proc sql noprint;
select max(n) into :n from
(select count(*) as n from have group by client,age,gender);
quit;

proc summary data=have nway;
class client age gender;
output out=want(drop=_:) idgroup(out[&amp;amp;n.] (timestamp PCLscore CDRISCscore)=);
run;
 &lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Jul 2022 13:16:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/824881#M325803</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-07-22T13:16:05Z</dc:date>
    </item>
    <item>
      <title>Re: Long Dataset to Wide - 1st Observation Missing when 2nd observation exists</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/855500#M338105</link>
      <description>&lt;P&gt;is there a modification to extend time points/observations beyond 2?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2023 04:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Long-Dataset-to-Wide-1st-Observation-Missing-when-2nd/m-p/855500#M338105</guid>
      <dc:creator>lberghammer</dc:creator>
      <dc:date>2023-01-25T04:24:01Z</dc:date>
    </item>
  </channel>
</rss>

