<?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: Retain non-missing by specific string to fill in missings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537777#M147957</link>
    <description>&lt;P&gt;Ok&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am gonna attempt with this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;"For every session_id, entries without "_load_time", "_start_time" or "_time" have missing time value.&lt;/U&gt; &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;We want to fill in missings by "_start_time" or "_load_time", "_start_time" comes in first because it is sorted after "_load_time".&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this consistent? &lt;STRONG&gt;Can you confirm there is only one occurence of entries with load_time, start_time respectively for a session_id? This is very important!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Also, for every session_id , are you sure anything at has missing values can be filled with the above logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Awaiting your response. Once you confirm, i will jump to code&lt;/P&gt;</description>
    <pubDate>Fri, 22 Feb 2019 17:50:03 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-02-22T17:50:03Z</dc:date>
    <item>
      <title>Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537549#M147860</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Edited&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble to retain the non-missing value in replace for the following missing value. The dataset with missings is as of the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;session_id         name                                               time   
    1            pd_confirm_resp_for_quest_adr_yes_ind_time            22.7      &lt;BR /&gt;    1            pd_confirm_next_time                                  23.7
    1            pd_load_time                                         13.3&lt;BR /&gt;    1            pd_confirm_lang_entry_ind                             .&lt;BR /&gt;    1            pd_confirm_lang_exit_ind                              .&lt;BR /&gt;    1            pd_confirm_close_browser_time                         24
    1            pd_login_resp_user_id_time                           2.1
    1            pd_login_login_time                                  12.2&lt;BR /&gt;    1            pd_login_lang_entry_ind                              .&lt;BR /&gt;    1            pd_login_lang_exit_ind                               .&lt;BR /&gt;    1            pd_login_close_browser_time                          36.8&lt;BR /&gt;    1            pd_respondent_p_first_name_time                       40.3&lt;BR /&gt;    1            pd_respondent_p_middle_name_time                     41.6&lt;BR /&gt;    1            pd_respondent_p_last_name_time                       35.8&lt;BR /&gt;    1            pd_respondent_load_time                              35.8&lt;BR /&gt;    1            pd_respondent_lang_entry_ind                         .&lt;BR /&gt;    1            pd_respondent_lang_exit_ind                          .&lt;BR /&gt;    1            pd_respondent_closemodal_time                        137.6&lt;BR /&gt;    1            pd_respondent_close_browser_time                     140&lt;BR /&gt;    1            pd_respondent_backmodal_time                         75&lt;BR /&gt;    1            pd_verifyaddress_next_time                           34.6&lt;BR /&gt;    1            pd_verifyaddress_load_time                           24.7&lt;BR /&gt;    1            pd_verifyaddress_lang_entry_ind                      .&lt;BR /&gt;    1            pd_verifyaddress_lang_exit_ind                       .&lt;BR /&gt;    1            pd_verifyaddress_h_occ_yes_ind_time                  33.7&lt;BR /&gt;    1            pd_verifyaddress_close_browser_time                  35.1&lt;BR /&gt;         &lt;BR /&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For each name contains string "_sessionstart_time" or "_load_time" or "_xxx_time" there will always be a time value, and I hope to use only "_sessionstart_time" or "_load_time" time values to fill in the missing values. If "_load_time" and "_sessionstart_time" exist for the same "yyy_xxx" entries (ex: "entry_login") then we will take "_sessionstart_time".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired output:&lt;/P&gt;&lt;P&gt;As a reminder, for simplicity, the sample dataset only has one session_id, but in reality, there are many session_id each defines a respondent. And names end with _ind is not the only factor that determines missing&amp;nbsp;time value. Missing time value is determined by name&amp;nbsp;not ending with _time. For example, names end with _test or _xxx other than _time have missing time values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notice&amp;nbsp;&lt;STRONG&gt;pd_login_lang_entry_ind &lt;/STRONG&gt;and&amp;nbsp; &lt;STRONG&gt;pd_login_lang_exit_ind&amp;nbsp;&lt;/STRONG&gt;should have missing time values because this group (login_lang) of names does not have _sessionstart_time or _load_time entries.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;session_id         name                                               time   
    1            pd_confirm_resp_for_quest_adr_yes_ind_time            22.7      &lt;BR /&gt;    1            pd_confirm_next_time                                  23.7
    1            pd_confirm_load_time                                  13.3&lt;BR /&gt;    1            pd_confirm_lang_entry_ind                             13.3&lt;BR /&gt;    1            pd_confirm_lang_exit_ind                              13.3&lt;BR /&gt;    1            pd_confirm_close_browser_time                         24
    1            pd_login_resp_user_id_time                           2.1
    1            pd_login_login_time                                  12.2&lt;BR /&gt;    1            pd_login_lang_entry_ind                              .&lt;BR /&gt;    1            pd_login_lang_exit_ind                               .&lt;BR /&gt;    1            pd_login_close_browser_time                          36.8&lt;BR /&gt;    1            pd_respondent_p_first_name_time                       40.3&lt;BR /&gt;    1            pd_respondent_p_middle_name_time                     41.6&lt;BR /&gt;    1            pd_respondent_p_last_name_time                       35.8&lt;BR /&gt;    1            pd_respondent_load_time                              35.8&lt;BR /&gt;    1            pd_respondent_lang_entry_ind                         35.8&lt;BR /&gt;    1            pd_respondent_lang_exit_ind                          35.8&lt;BR /&gt;    1            pd_respondent_closemodal_time                        137.6&lt;BR /&gt;    1            pd_respondent_close_browser_time                     140&lt;BR /&gt;    1            pd_respondent_backmodal_time                         75&lt;BR /&gt;    1            pd_verifyaddress_next_time                           34.6&lt;BR /&gt;    1            pd_verifyaddress_load_time                           24.7&lt;BR /&gt;    1            pd_verifyaddress_lang_entry_ind                      24.7&lt;BR /&gt;    1            pd_verifyaddress_lang_exit_ind                       24.7&lt;BR /&gt;    1            pd_verifyaddress_h_occ_yes_ind_time                  33.7&lt;BR /&gt;    1            pd_verifyaddress_close_browser_time                  35.1&lt;BR /&gt;         &lt;BR /&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I have so far does not produce the desired output, but the outcome is very close:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have; 
set have;
t1 = scan(strip(name), 2, '_');
t3 = scan(strip(name), 3, '_');
run;

proc sort data = have; by session_id t1 descending t3;run;

data want;
&amp;nbsp;drop temp;
&amp;nbsp; set have;
&amp;nbsp;&amp;nbsp; by session_id t1 descending t3 value;
&amp;nbsp;&amp;nbsp; retain temp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.session_id or first.t1 or first.t3 then temp=.;
&amp;nbsp;&amp;nbsp;&amp;nbsp; if t3 = "load" or t3 = "sessionstart" and not missing(time) then temp=time;
&amp;nbsp;&amp;nbsp;&amp;nbsp; else if missing(time) then time = temp;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Code output:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;STRONG&gt;session_id         name                                               time   
    1            pd_confirm_resp_for_quest_adr_yes_ind_time            22.7      &lt;BR /&gt;    1            pd_confirm_next_time                                  23.7
    1            pd_confirm_load_time                                  13.3&lt;BR /&gt;    1            pd_confirm_lang_entry_ind                             13.3&lt;BR /&gt;    1            pd_confirm_lang_exit_ind                              13.3&lt;BR /&gt;    1            pd_confirm_close_browser_time                         24
    1            pd_login_resp_user_id_time                           2.1
    1            pd_login_login_time                                  12.2&lt;BR /&gt;    1            pd_login_lang_entry_ind                              35.8&lt;BR /&gt;    1            pd_login_lang_exit_ind                               35.8&lt;BR /&gt;    1            pd_login_close_browser_time                          36.8&lt;BR /&gt;    1            pd_respondent_p_first_name_time                       40.3&lt;BR /&gt;    1            pd_respondent_p_middle_name_time                     41.6&lt;BR /&gt;    1            pd_respondent_p_last_name_time                       35.8&lt;BR /&gt;    1            pd_respondent_load_time                              35.8&lt;BR /&gt;    1            pd_respondent_lang_entry_ind                         35.8&lt;BR /&gt;    1            pd_respondent_lang_exit_ind                          35.8&lt;BR /&gt;    1            pd_respondent_closemodal_time                        137.6&lt;BR /&gt;    1            pd_respondent_close_browser_time                     140&lt;BR /&gt;    1            pd_respondent_backmodal_time                         75&lt;BR /&gt;    1            pd_verifyaddress_next_time                           34.6&lt;BR /&gt;    1            pd_verifyaddress_load_time                           24.7&lt;BR /&gt;    1            pd_verifyaddress_lang_entry_ind                      24.7&lt;BR /&gt;    1            pd_verifyaddress_lang_exit_ind                       24.7&lt;BR /&gt;    1            pd_verifyaddress_h_occ_yes_ind_time                  33.7&lt;BR /&gt;    1            pd_verifyaddress_close_browser_time                  35.1&lt;BR /&gt;         &lt;BR /&gt;&lt;/STRONG&gt;&lt;/PRE&gt;&lt;P&gt;The code does not work on&amp;nbsp;&lt;STRONG&gt;pd_login_lang_entry_ind &lt;/STRONG&gt;and&amp;nbsp; &lt;STRONG&gt;pd_login_lang_exit_ind&amp;nbsp;&lt;/STRONG&gt;instead of being missing, they took the value of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;pd_respondent_load_time.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Grateful for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 05:19:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537549#M147860</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-27T05:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537560#M147862</link>
      <description>&lt;P&gt;Looking at session_id=2, pd_device has time=11. But that value is only provided in a later observation whith pd_load and time=11. Your code would not achieve that. You use the term "retain"but that only allows for values to be carried foreward and not backward. Probably your way out is to do a double pass. First make a set of replacement values and then merge that with the original data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can't find time to do that exercise for you. Maybe you find it a challenge yourself?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;-- Jan.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 22:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537560#M147862</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2019-02-21T22:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537561#M147863</link>
      <description>&lt;P&gt;EDITED to use keep statement instead of drop&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input session_id         name  : $12.       time;
cards;
    1            pd_load           12
    1            entry_load        13
    1            entry_start       12
    1            pd_time           13
    1            entry_time        9
    1            entry_text         .
    1            pd_text            .
    1            pd_device          .
    2            pd_device          .
    2            pd_text            .
    2            pd_time            7
    2            pd_load            11 
    3            pd_text            .
    3            pd_load            10
    3            entry_start        4
    3            entry_text         .
	;

	proc sort data=have out=_have;
	by session_id descending time;
	run;

data want;
if _n_=1 then do;
dcl hash H (multidata:'y') ;
   h.definekey  ("session_id","t1") ;
   h.definedata ("t2","ti") ;
   h.definedone () ;
end;
do until(last.session_id);
set _have end=lr;
by session_id;
t1=scan(name,1,'_');
t2=scan(name,2,'_');
ti=time;
if time&amp;gt;. then rc=h.add();
else do;
do rc=h.find() by 0 while(rc=0);
if t2='start' then start=ti;
else if t2='load' then load=ti;
rc=h.find_next();
end;
time=Coalesce(start,load);
end;
output;
end;
keep session_id name time;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 23:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537561#M147863</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-21T23:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537568#M147867</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input session_id         name  : $12.       time;
cards;
    1            pd_load           12
    1            entry_load        13
    1            entry_start       12
    1            pd_time           13
    1            entry_time        9
    1            entry_text         .
    1            pd_text            .
    1            pd_device          .
    2            pd_device          .
    2            pd_text            .
    2            pd_time            7
    2            pd_load            11 
    3            pd_text            .
    3            pd_load            10
    3            entry_start        4
    3            entry_text         .
	;

proc sql;
create table want(drop=t1 t2) as
select a.session_id,a.name,t1,ifn(a.time=.,b.time,a.time)as time ,t2
from have a left join (select session_id,scan(name,1,'_') as t1,scan(name,-1,'_') as t2,time from have where scan(name,-1,'_') in ('start','load')) b
on a.session_id=b.session_id and scan(a.name,1,'_')=t1
group by a.session_id,a.name,t1
having max(t2)=t2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Feb 2019 23:43:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537568#M147867</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-21T23:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537578#M147870</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;The reason why I used index() was that the actual names have more than one underscore. Such as PD_LOGIN_LANG_ENTRY_IND or PD_CONFIRM_LOAD_TIME (_load) or PD_LANDING_SESSIONSTART_TIME (_start). How should I implement scan() in this case? PD_XXX_LOAD_TIME, XXX is not always the same value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For In the actual dataset I should be subsetting by "_LOAD_TIME" and "_SESSIONSTART_TIME".&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 02:53:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537578#M147870</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T02:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537581#M147872</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; I changed sample dataset to imitate the actual name values.</description>
      <pubDate>Fri, 22 Feb 2019 03:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537581#M147872</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T03:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537582#M147873</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; &amp;nbsp;Can you post a more &lt;STRONG&gt;representative&lt;/STRONG&gt; sample of your real i.e &lt;STRONG&gt;data have&lt;/STRONG&gt; and &lt;STRONG&gt;data want&lt;/STRONG&gt;?&lt;/P&gt;
&lt;P&gt;That can help anybody have the right approavh&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 03:04:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537582#M147873</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T03:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537584#M147875</link>
      <description>@novinsorin I made another update to the name values. Now I think it is the closest to the actual dataset. Sorry about the delay.</description>
      <pubDate>Fri, 22 Feb 2019 03:13:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537584#M147875</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T03:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537592#M147879</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; &amp;nbsp;See if this works, I have modified to handle&amp;nbsp; your updated HAVE&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input session_id         name  : $35.       time;
cards;
    1            pd_login_load_time             12
    1            entry_confirm_load_time        13
    1            entry_confirm_start_time       12
    1            pd_save_time                   13
    1            entry_login_time               9
    1            entry_login_text               .
    1            pd_login_text                  .
    1            pd_login_device                .
    2            pd_confirm_device              .
    2            pd_confirm_text                .
    2            pd_login_time                  7
    2            pd_confirm_load_time           11 
    3            pd_login_text                  .
    3            pd_login_load_time             10
    3            entry_confirm_start_time        4
    3            entry_confirm_text              .
	;


proc sort data=have out=_have;
by session_id descending time;
run;

data want;
if _n_=1 then do;
dcl hash H (multidata:'y') ;
   h.definekey  ("session_id","t1") ;
   h.definedata ("t2","ti") ;
   h.definedone () ;
end;
do until(last.session_id);
set _have end=lr;
by session_id;
t1=scan(name,1,'_'); 
k= findw(name,'load','_');
k1=	findw(name,'start','_');
if k&amp;gt;0 then t2= substr(name,k,4) ;
else if k1&amp;gt;0 then t2= substr(name,k1,5);
ti=time;
if time&amp;gt;. and sum(k,k1)&amp;gt;0 then rc=h.add();
else if time=. then do;
    do rc=h.find() by 0 while(rc=0);
    if t2='start' then start=ti;
     else if t2='load' then load=ti;
      rc=h.find_next();
     end;
time=Coalesce(start,load);
end;
output;
end;
keep session_id name time;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 03:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537592#M147879</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T03:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537596#M147881</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; I looked more into the dataset, and realized the name values all starts with “pd_” which will need to alter t1 in the program. It should be t1 = scan(name,2,'_'). However, just by extracting one word is not enough to define unique t1, some name such as pd_HH_dash_lang_entry_ind and pd_HH_dash_load_time will need more than one word. Sorry, the original dataset is very large, it was hard to find the exact pattern, but I think I finally have the finalized version of the sample dataset, please see my most recent updates on the original post. Thank you so much for your patience.</description>
      <pubDate>Fri, 22 Feb 2019 04:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537596#M147881</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T04:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537597#M147882</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; it's a bit too late here and Im half asleep. Let me take a look in the morning. In the mean time I'm sure somebody else in a different time zone might respond. Hang in there&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 04:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537597#M147882</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T04:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537735#M147935</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ok, I think I need help from you in clarifying what makes it one unique set(group) .&lt;/P&gt;
&lt;P&gt;For example., your example&amp;nbsp;&lt;SPAN&gt;pd_HH_dash_lang_entry_ind and pd_HH_dash_load_time , what exacts would be classed as a group.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Since the discussion has been going back and forth, I would need you to thoroughly revisit the data samples in your original and clearly establish what constitutes a group.&amp;nbsp; This is crucial as this forms the basis for key variables that I would want to be defined in the hash object or as look up/join keys for that matter be it sql or hash&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Take your time and respond here with utmost clarity if you can.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:07:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537735#M147935</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T16:07:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537757#M147947</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205" target="_blank" rel="noopener"&gt;@novinosrin&lt;/A&gt; I believe a group is defined by the term comes before "_load_time" or "_start_time" and after "pd_" therefore, in this case, the group will be "HH_dash" .&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 16:57:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537757#M147947</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T16:57:01Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537764#M147952</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hmm, Ok taking this example below i.e your latest sample&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All records have the same prefix&lt;STRONG&gt; pd_&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;So obviously we need to segregate within. So can you manually show me the segregated&amp;nbsp; groups with each groups &lt;STRONG&gt;load &lt;/STRONG&gt;and &lt;STRONG&gt;start&lt;/STRONG&gt;&amp;nbsp;in place for the below sample? We really have to get over this roadblock&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV align="center"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.HAVE" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_confirm_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_confirm_start_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_save_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_login_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_confirm_text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_device&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_confirm_device&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_confirm_text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_confirm_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_login_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_confirm_start_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_entry_confirm_text&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_HH_dash_lang_entry_ind&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_HH_dash_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_dob_close_browser_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_dob_lang_entry_ind&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_dob_lang_exit_ind&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_dob_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_dob_next_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_home_lang_entry_ind&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_home_lang_exit_ind&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_home_lang_load_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="l data"&gt;pd_home_lang_next_time&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537764#M147952</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T17:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537770#M147955</link>
      <description>&lt;P&gt;Hope the following helps on clarification. For every session_id, entries without "_load_time", "_start_time" or "_time" have missing time value. We want to fill in missings by "_start_time" or "_load_time", "_start_time" comes in first because it is sorted after "_load_time".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;pd_login_load_time (login with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_confirm_load_time (entry_confirm with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_confirm_start_time (entry_confirm with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_save_time ("_time " always have a time value, no need to fill in missing for this type of entries)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_login_time ("_time" time value not missing)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_confirm_text (entry_confirm)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_login_text (login)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_login_device (login)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_confirm_device (confirm)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_confirm_text (confirm)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_login_time (login)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_confirm_load_time (confirm with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_login_text (login)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_login_load_time (login with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_confirm_start_time (entry_confirm)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_entry_confirm_text (entry_confirm)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_HH_dash_lang_entry_ind (HH_dash)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_HH_dash_load_time (HH_dash with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_dob_close_browser_time ("_time" time value not missing)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_dob_lang_entry_ind (dob)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_dob_lang_exit_ind (dob)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_dob_load_time (dob with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_dob_next_time ("_time" time value not missing)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_home_lang_entry_ind (home_lang)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_home_lang_exit_ind (home_lang)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_home_lang_load_time (home_lang with time value)&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;pd_home_lang_next_time ("_time" time value not missing)&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:22:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537770#M147955</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T17:22:40Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537776#M147956</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; &amp;nbsp;Sounds like pattern is really hard as in some the first 2 words extract makes it a group and in others it happens to be the 1st 3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example&lt;/P&gt;
&lt;TABLE style="width: 391px; height: 210px;" cellspacing="0" cellpadding="5"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#339966"&gt;&lt;STRONG&gt;pd_login_text (login)&amp;nbsp; &amp;nbsp;/*first 2*/&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#339966"&gt;pd_login_load_time (login with time value)&lt;STRONG&gt;/*first 2*/&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#FF00FF"&gt;pd_entry_confirm_start_time (entry_confirm) /*first 3*/&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#FF00FF"&gt;pd_entry_confirm_text (entry_confirm) /*first 3*/&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#00FF00"&gt;pd_HH_dash_lang_entry_ind (HH_dash) /*first 3*/&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;&lt;FONT color="#00FF00"&gt;pd_HH_dash_load_time (HH_dash with time value)&amp;nbsp;) /*first 3*/&lt;/FONT&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 39px;"&gt;
&lt;TD style="width: 377px; height: 39px;"&gt;pd_dob_close_browser_time ("_time" time value not missing) /*first 2*/&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;pd_dob_lang_entry_ind (dob) /*first 2*/&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;pd_dob_lang_exit_ind (dob) /*first 2*/&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 19px;"&gt;
&lt;TD style="width: 377px; height: 19px;"&gt;pd_dob_load_time (dob with time value) /*first 2*/&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Isn't there any logical way to group? I mean a consistent pattern?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537776#M147956</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T17:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537777#M147957</link>
      <description>&lt;P&gt;Ok&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am gonna attempt with this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&lt;U&gt;"For every session_id, entries without "_load_time", "_start_time" or "_time" have missing time value.&lt;/U&gt; &lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;We want to fill in missings by "_start_time" or "_load_time", "_start_time" comes in first because it is sorted after "_load_time".&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this consistent? &lt;STRONG&gt;Can you confirm there is only one occurence of entries with load_time, start_time respectively for a session_id? This is very important!&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Also, for every session_id , are you sure anything at has missing values can be filled with the above logic&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Awaiting your response. Once you confirm, i will jump to code&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 17:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537777#M147957</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T17:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537784#M147960</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alright, I think&amp;nbsp; if my understanding is correct, the following should solve the problem&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input session_id         name  : $50.       time;
cards;
    1            pd_login_load_time                     12
    1            pd_entry_confirm_load_time             13
    1            pd_entry_confirm_start_time            12
    1            pd_save_time                           13
    1            pd_entry_login_time                     9
    1            pd_entry_confirm_text                  12
    1            pd_login_text                          12
    1            pd_login_device                        12
    2            pd_confirm_device                      11
    2            pd_confirm_text                        11
    2            pd_login_time                           7
    2            pd_confirm_load_time                   11 
    3            pd_login_text                          10
    3            pd_login_load_time                     10
    3            pd_entry_confirm_start_time             4
    3            pd_entry_confirm_text                   4
    4            pd_HH_dash_lang_entry_ind              5
    4            pd_HH_dash_load_time                   5
    5            pd_dob_close_browser_time              6
    5            pd_dob_lang_entry_ind                  23
    5            pd_dob_lang_exit_ind                   23
    5            pd_dob_load_time                       23
    5            pd_dob_next_time                       11
    5            pd_home_lang_entry_ind                 16
    5            pd_home_lang_exit_ind                  16
    5            pd_home_lang_load_time                 16
    5            pd_home_lang_next_time                 18
	;

proc sort data=have out=_have;
by session_id descending time;
run;

data want;
if _n_=1 then do;
dcl hash H (multidata:'y') ;
   h.definekey  ("session_id") ;
   h.definedata ("t1","ti") ;
   h.definedone () ;
end;
do until(last.session_id);
set _have end=lr;
by session_id;
if time&amp;gt;. then 
	do;
		k=findw(name,'load','_');
		k1=findw(name,'start','_');
		ti=time;
		if k&amp;gt;0 then t1='load';
		else if k1&amp;gt;0 then t1='start';
		if sum(k,k1)&amp;gt;0 then rc=h.add() ;
   end;
else if time=. then do;
    do rc=h.find() by 0 while(rc=0);
    if t1='start' then start=ti;
     else if t1='load' then load=ti;
      rc=h.find_next();
     end;
time=Coalesce(start,load);
end;
output;
end;
keep session_id name time;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And for some reason, I feel silly that somewhere I overlooked and didn't comprehend properly. Really have to work on my communication and comprehension skills.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. No need to find patterns&lt;/P&gt;
&lt;P&gt;2. We are going with session_id has keys&lt;/P&gt;
&lt;P&gt;3. Populate non missings with start,load in hash object&lt;/P&gt;
&lt;P&gt;4. Look up using session_id as key&lt;/P&gt;
&lt;P&gt;5. Fetch the time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and we are done!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Feb 2019 18:08:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537784#M147960</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-22T18:08:23Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537791#M147964</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt; This is a para-dataset. Each session_id represents a user, and the user is jumping from one screen to another, a screen name is defined by the first or the first+second word after pd_. Therefore, the answer would be no for each session there will be multiple load_time and start_time since the user is switching screens. Thank you for your patience.</description>
      <pubDate>Fri, 22 Feb 2019 18:13:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/537791#M147964</guid>
      <dc:creator>lydiawawa</dc:creator>
      <dc:date>2019-02-22T18:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Retain non-missing by specific string to fill in missings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/538651#M148299</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30435"&gt;@lydiawawa&lt;/a&gt;&amp;nbsp; &amp;nbsp;Did the above work for you?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 15:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Retain-non-missing-by-specific-string-to-fill-in-missings/m-p/538651#M148299</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-02-26T15:43:58Z</dc:date>
    </item>
  </channel>
</rss>

