<?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: How to access the values of the variables in from the last observation in a dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323783#M71809</link>
    <description>&lt;P&gt;I appended the last to row to the original dataset, so I dont want to do a set statement again to redo it&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2017 21:32:04 GMT</pubDate>
    <dc:creator>UPEN</dc:creator>
    <dc:date>2017-01-10T21:32:04Z</dc:date>
    <item>
      <title>How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323770#M71799</link>
      <description>&lt;P&gt;I have a dataset like this, how to access the each value in the last observation? Let's say, I want the last values for the varaibles var2, var3 and var4 whose values are&amp;nbsp; 3, 7.5, 8. I know that we cannot use the last. beacuse my data should not be sorted or grouped. Please help.&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV align="center"&gt;Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; var1 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; var2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var3 &amp;nbsp;&amp;nbsp; var4 &lt;TABLE cellspacing="0" cellpadding="5"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6.0&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;8.0&lt;/TD&gt;&lt;TD&gt;11&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;9.0&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;7.5&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 10 Jan 2017 20:59:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323770#M71799</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T20:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323772#M71800</link>
      <description>&lt;P&gt;What are you planning to do with said 'last' observation? Is the only way to identify this observation is that its the last record?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could merge the data with itself, but keep only the last row in the second dataset. This is only one method, it depends on what you're trying to do.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323772#M71800</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-10T21:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323774#M71802</link>
      <description>&lt;P&gt;My goal is to replace the missing values with last value of that record, so I need to access the last values&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:03:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323774#M71802</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T21:03:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323775#M71803</link>
      <description>&lt;P&gt;What if the last observation has a missing value for VAR3?&amp;nbsp; Do you want to go back to the next-to-last&lt;/P&gt;
&lt;P&gt;&amp;nbsp;observation in that case?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:09:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323775#M71803</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-10T21:09:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323777#M71804</link>
      <description>&lt;P&gt;My last observation wont be having missing values. Even its missing I want to replace with the missing itself or leave.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323777#M71804</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T21:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323778#M71805</link>
      <description>&lt;P&gt;You can use this method to merge the record in. You can use COALESCE() to replace a value with antoher if missing.&lt;/P&gt;
&lt;P&gt;If you don't know the number of obs, you can pre calculate it using a few different options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var1-var5;
cards;
1	0	1	6.0	9
4	5	8	8	7
3	6	.	8.0	11
4	5	4	9.0	12
6	5	5	.	10
3	5	3	7.5	8
;
run;

data want;
set have;
if _n_ = 1 then do;
set have (firstobs=6 rename=var1-var5 = nvar1-nvar5);
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323778#M71805</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-10T21:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323780#M71807</link>
      <description>&lt;P&gt;OK, here's a generic way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;if _n_=1 then set have nobs=_nobs_ point=_nobs_ (rename=(var1-var4 = replacement_1 - replacement_4));&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;*** Add any statements you want here to change VAR1 - VAR4 based on replacement variables;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:26:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323780#M71807</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-10T21:26:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323783#M71809</link>
      <description>&lt;P&gt;I appended the last to row to the original dataset, so I dont want to do a set statement again to redo it&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323783#M71809</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T21:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323786#M71812</link>
      <description>&lt;P&gt;The actual question is... I have a dataset with misssing values, now I have to replace the missing values in each colums with the average of its respective column.&lt;/P&gt;&lt;P&gt;My appraoch - I took the mean values in to the variables using proc means and then appended that row to the original dataset, I did this beacause if there are 200 variables I thought this would be easy. But I think this is not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please tell me how would you achieve this?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:37:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323786#M71812</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T21:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323793#M71817</link>
      <description>&lt;P&gt;....Feel free to start there next time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use PROC STDIZE instead, with the MISSING= and REPONLY options you can replace missing values with a variety of different options, 0, mean, median, etc.&lt;/P&gt;
&lt;P&gt;See the documentation for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc stdize data=have out=want reponly  missing=mean;
var var2-var5;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Jan 2017 21:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323793#M71817</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-10T21:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to access the values of the variables in from the last observation in a dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323796#M71820</link>
      <description>&lt;P&gt;sure. Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 22:00:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-access-the-values-of-the-variables-in-from-the-last/m-p/323796#M71820</guid>
      <dc:creator>UPEN</dc:creator>
      <dc:date>2017-01-10T22:00:57Z</dc:date>
    </item>
  </channel>
</rss>

