<?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: Impute values of some (not all) variables based on where participant ID falls in alphabetical or in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804516#M316830</link>
    <description>&lt;P&gt;Thanks, this worked to an extent but only for the first instance of a participant with missing values. Where there are multiple in a row (ex, ABC1002 and ABC1003 are both missing in the example I gave) it only imputed values for ABC1002 but not ABC1003. Is there a way to correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Mar 2022 14:19:37 GMT</pubDate>
    <dc:creator>lh50</dc:creator>
    <dc:date>2022-03-28T14:19:37Z</dc:date>
    <item>
      <title>Impute values of some (not all) variables based on where participant ID falls in alphabetical order</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804104#M316618</link>
      <description>&lt;P&gt;I have a dataset where participants were sampled from multiple locations that includes several location-specific variables in addition to participant-specific test results. After merging with another results dataset, some participant IDs from the second dataset have no link in the first so they are missing the location information. However, it is obvious which location they correspond to based on their ID value. For example, ABC1002 in the table below comes from the same school/village/region as ABC1001 and 1003.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;id&lt;/TD&gt;&lt;TD&gt;result&lt;/TD&gt;&lt;TD&gt;result2&lt;/TD&gt;&lt;TD&gt;village&lt;/TD&gt;&lt;TD&gt;school_id&lt;/TD&gt;&lt;TD&gt;school_name&lt;/TD&gt;&lt;TD&gt;geopoint_lat&lt;/TD&gt;&lt;TD&gt;geopoint_lng&lt;/TD&gt;&lt;TD&gt;region&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1001&lt;/TD&gt;&lt;TD&gt;NEGATIVE&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;5555&lt;/TD&gt;&lt;TD&gt;School A&lt;/TD&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;ABC1002&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&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;ABC1003&lt;/TD&gt;&lt;TD&gt;NEGATIVE&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;5555&lt;/TD&gt;&lt;TD&gt;School A&lt;/TD&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;999&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question: is there an easy way to impute the location-specific variables for participants like this but *not* other variables like 'result' and 'result2' that are specific to each participant? I could obviously do this one at a time, but hoping there is a quicker fix.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 15:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804104#M316618</guid>
      <dc:creator>lh50</dc:creator>
      <dc:date>2022-03-25T15:05:28Z</dc:date>
    </item>
    <item>
      <title>Re: Impute values of some (not all) variables based on where participant ID falls in alphabetical or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804110#M316620</link>
      <description>&lt;P&gt;As long as &lt;U&gt;&lt;STRONG&gt;none&lt;/STRONG&gt;&lt;/U&gt; of the first ID in a sequence are missing the values something like this:&lt;/P&gt;
&lt;PRE&gt;Data have;
  input id $	result $	result2	village $	 ;
datalines;
ABC1001	NEGATIVE	2	A	
ABC1002	. 	 	 	. 	. 	 	 	 
ABC1003	NEGATIVE	2	A	
;

data want;
   set have;
   village=coalescec(village,lag(village));
run;
 	 	 	 	 	 	 	 &lt;/PRE&gt;
&lt;P&gt;The Coalescec (for character) and Coalsesce (for numeric) returns the first value that is not missing. The LAG function, when used carefully, returns the value of a variable on the previous record. Actually you can look back quite a number of records but leave that to an actual problem.&lt;/P&gt;
&lt;P&gt;Do use the Coalesce function if your variable is numeric. You didn't provide enough information to tell so I create a small example using just a few variables.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2022 15:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804110#M316620</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-25T15:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: Impute values of some (not all) variables based on where participant ID falls in alphabetical or</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804516#M316830</link>
      <description>&lt;P&gt;Thanks, this worked to an extent but only for the first instance of a participant with missing values. Where there are multiple in a row (ex, ABC1002 and ABC1003 are both missing in the example I gave) it only imputed values for ABC1002 but not ABC1003. Is there a way to correct this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 14:19:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Impute-values-of-some-not-all-variables-based-on-where/m-p/804516#M316830</guid>
      <dc:creator>lh50</dc:creator>
      <dc:date>2022-03-28T14:19:37Z</dc:date>
    </item>
  </channel>
</rss>

