<?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 How to pull weights of missing values from other column values? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711353#M219122</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to add last 2 columns in my data "Time_yrs_lower_limit' and "Time_yrs_higher_limit".&lt;/P&gt;&lt;P&gt;For doing this, here are the steps&lt;/P&gt;&lt;P&gt;1. Identify previous value of 'Time_yrs' for which 'Rate' value is not null&lt;/P&gt;&lt;P&gt;2. Put the value in cell&amp;nbsp;"Time_yrs_lower_limit'&lt;/P&gt;&lt;P&gt;3.Identify next value of 'Time_yrs' for which 'Rate' value is not null&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Put the value in cell&amp;nbsp;"Time_yrs_higher_limit'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;TD&gt;Time_yrs&lt;/TD&gt;&lt;TD&gt;Rate&lt;/TD&gt;&lt;TD&gt;Time_yrs_Lower_limit&lt;/TD&gt;&lt;TD&gt;Time_yrs_higher_limit&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-May-21&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;0.166285199&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-Mar-22&lt;/TD&gt;&lt;TD&gt;1.787816564&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-Apr-22&lt;/TD&gt;&lt;TD&gt;1.872689938&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-May-22&lt;/TD&gt;&lt;TD&gt;1.954825462&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-May-22&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;TD&gt;0.210218179&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;INFILE DATALINES DSD;&lt;BR /&gt;INPUT&lt;BR /&gt;DATE : DATE9.&lt;BR /&gt;Time_yrs&lt;BR /&gt;Rate&lt;BR /&gt;;&lt;BR /&gt;FORMAT DATE DATE9.&lt;BR /&gt;;&lt;BR /&gt;DATALINES;&lt;BR /&gt;31May2021, 0.999315537, 0.166285199&lt;BR /&gt;15Mar2022, 1.787816564,&lt;BR /&gt;15Apr2022, 1.872689938,&lt;BR /&gt;15May2022, 1.954825462,&lt;BR /&gt;31May2022, 1.998631075, 0.210218179 ,&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jan 2021 07:05:05 GMT</pubDate>
    <dc:creator>rohitdev_ds</dc:creator>
    <dc:date>2021-01-14T07:05:05Z</dc:date>
    <item>
      <title>How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711353#M219122</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to add last 2 columns in my data "Time_yrs_lower_limit' and "Time_yrs_higher_limit".&lt;/P&gt;&lt;P&gt;For doing this, here are the steps&lt;/P&gt;&lt;P&gt;1. Identify previous value of 'Time_yrs' for which 'Rate' value is not null&lt;/P&gt;&lt;P&gt;2. Put the value in cell&amp;nbsp;"Time_yrs_lower_limit'&lt;/P&gt;&lt;P&gt;3.Identify next value of 'Time_yrs' for which 'Rate' value is not null&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Put the value in cell&amp;nbsp;"Time_yrs_higher_limit'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;DATE&lt;/TD&gt;&lt;TD&gt;Time_yrs&lt;/TD&gt;&lt;TD&gt;Rate&lt;/TD&gt;&lt;TD&gt;Time_yrs_Lower_limit&lt;/TD&gt;&lt;TD&gt;Time_yrs_higher_limit&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-May-21&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;0.166285199&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-Mar-22&lt;/TD&gt;&lt;TD&gt;1.787816564&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-Apr-22&lt;/TD&gt;&lt;TD&gt;1.872689938&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;15-May-22&lt;/TD&gt;&lt;TD&gt;1.954825462&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;0.999315537&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;31-May-22&lt;/TD&gt;&lt;TD&gt;1.998631075&lt;/TD&gt;&lt;TD&gt;0.210218179&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code&lt;/P&gt;&lt;P&gt;data have;&lt;BR /&gt;INFILE DATALINES DSD;&lt;BR /&gt;INPUT&lt;BR /&gt;DATE : DATE9.&lt;BR /&gt;Time_yrs&lt;BR /&gt;Rate&lt;BR /&gt;;&lt;BR /&gt;FORMAT DATE DATE9.&lt;BR /&gt;;&lt;BR /&gt;DATALINES;&lt;BR /&gt;31May2021, 0.999315537, 0.166285199&lt;BR /&gt;15Mar2022, 1.787816564,&lt;BR /&gt;15Apr2022, 1.872689938,&lt;BR /&gt;15May2022, 1.954825462,&lt;BR /&gt;31May2022, 1.998631075, 0.210218179 ,&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 07:05:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711353#M219122</guid>
      <dc:creator>rohitdev_ds</dc:creator>
      <dc:date>2021-01-14T07:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711359#M219126</link>
      <description>&lt;P&gt;Try next not tested code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have; by date; run;
data temp;
 set have;
     retain time_yrs_lower_limit;
	 if _N_ = 1 then output;
	 if not missing(rate) then 
	    time_yrs_lower_limit = time_yrs;
run;

proc sort data=have; by descending date; run;
data want;
 set temp;
     retain Time_yrs_higher_limit;
	 if _N_ = 1 then output;
	 if not missing(rate) then 
	    Time_yrs_higher_limit = time_yrs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 07:37:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711359#M219126</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-14T07:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711370#M219136</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
INFILE DATALINES DSD;
INPUT
DATE : DATE9.
Time_yrs
Rate
;
FORMAT DATE DATE9.
;
DATALINES;
31May2021, 0.999315537, 0.166285199
15Mar2022, 1.787816564,
15Apr2022, 1.872689938,
15May2022, 1.954825462,
31May2022, 1.998631075, 0.210218179 ,
;

data w1;
set have end=done;
retain Time_yrs_Lower_limit;
if rate ne . then Time_yrs_Lower_limit = .;
output;
if rate ne . then Time_yrs_Lower_limit = Time_yrs;
run;

proc sort data=w1;
by descending date;
run;

data want;
set w1 end=done;
retain Time_yrs_higher_limit;
if rate ne . then Time_yrs_higher_limit = .;
output;
if rate ne . then Time_yrs_higher_limit = Time_yrs;
run;

proc sort data=want;
by date;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 08:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711370#M219136</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-14T08:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711375#M219140</link>
      <description>&lt;P&gt;I have tested and fixed my previous code and hope this is what you want:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	INFILE DATALINES DSD;
	INPUT DATE : DATE9. Time_yrs Rate;
	FORMAT DATE DATE9.;
DATALINES;
31May2021, 0.999315537, 0.166285199
15Mar2022, 1.787816564,
15Apr2022, 1.872689938,
15May2022, 1.954825462,
31May2022, 1.998631075, 0.210218179 ,
;
run;

proc sort data=have; by date; run;
data temp;
 set have;
     retain ID time_yrs_lower_limit;
     ID = _n_;
	 if rate then do; 
	    time_yrs_lower_limit=.; 
	    output; 
		time_yrs_lower_limit = time_yrs;
	 end;
	 else output;
run;

proc sort data=temp out=tmps; by descending ID ; run;
data want;
 set tmps;
     retain Time_yrs_higher_limit;
	 if rate then do; 
	    Time_yrs_higher_limit=.; 
	    output; 
		Time_yrs_higher_limit = time_yrs;
	 end;
	 else output;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 09:01:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711375#M219140</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-14T09:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711459#M219181</link>
      <description>&lt;P&gt;My two cents.&amp;nbsp; I really thought this would be more straight forward when I started this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
  CREATE TABLE WORK.Want AS 
    SELECT 
      *, 
      ifn( missing(rate), MIN(Time_yrs), . ) AS Time_yrs_lower_limit, 
      ifn( missing(rate), Max(Time_yrs), . ) AS Time_yrs_higher_limit      
    FROM have
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 14:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711459#M219181</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-14T14:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711590#M219232</link>
      <description>Thank you Sir. This works.</description>
      <pubDate>Fri, 15 Jan 2021 02:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711590#M219232</guid>
      <dc:creator>rohitdev_ds</dc:creator>
      <dc:date>2021-01-15T02:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to pull weights of missing values from other column values?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711591#M219233</link>
      <description>&lt;P&gt;thank you for your help.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2021 02:46:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-pull-weights-of-missing-values-from-other-column-values/m-p/711591#M219233</guid>
      <dc:creator>rohitdev_ds</dc:creator>
      <dc:date>2021-01-15T02:46:31Z</dc:date>
    </item>
  </channel>
</rss>

