<?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 keep the first value of a variable to other observations? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573249#M161803</link>
    <description>&lt;P&gt;Suppose I have a dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;--Have--     
KIND  KIND_CD  var1    var2...    
A     1         1    
A     .         2
A     1         3
.     1         4
.     1         5&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;All observations belongs to same KIND, but for some reason some values are missing. The dataset I want is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;--want--     
KIND  KIND_CD  var1   var2...   
A     1         1    
A     1         2
A     1         3
A     1         4
A     1         5&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to create KIND_1 and KIND_CD_1 to retain the non-missing value. But since I have lots of 'KIND' variables, this may not be a good method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2019 22:42:57 GMT</pubDate>
    <dc:creator>Ada77</dc:creator>
    <dc:date>2019-07-12T22:42:57Z</dc:date>
    <item>
      <title>How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573249#M161803</link>
      <description>&lt;P&gt;Suppose I have a dataset:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;--Have--     
KIND  KIND_CD  var1    var2...    
A     1         1    
A     .         2
A     1         3
.     1         4
.     1         5&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;All observations belongs to same KIND, but for some reason some values are missing. The dataset I want is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;--want--     
KIND  KIND_CD  var1   var2...   
A     1         1    
A     1         2
A     1         3
A     1         4
A     1         5&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I tried to create KIND_1 and KIND_CD_1 to retain the non-missing value. But since I have lots of 'KIND' variables, this may not be a good method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 22:42:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573249#M161803</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-12T22:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573250#M161804</link>
      <description>It looks like you have read in a report instead of raw data,often where cells are combined via merged cells?&lt;BR /&gt;&lt;BR /&gt;Anways, RETAIN is the correct approach, but how many variables do you need to do this with? If it's a lot an array or macro approach may be needed.</description>
      <pubDate>Fri, 12 Jul 2019 22:48:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573250#M161804</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-12T22:48:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573251#M161805</link>
      <description>I have 8 variable to do that. Do you think make 8 new variable and RETAIN them is suitable here? If I use RETAIN I also should RENAME these new variables afterward</description>
      <pubDate>Fri, 12 Jul 2019 22:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573251#M161805</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-12T22:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573253#M161806</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/257597"&gt;@Ada77&lt;/a&gt;&amp;nbsp; &amp;nbsp;Can you please post a comprehensive and better representative sample ?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573253#M161806</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-12T23:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573254#M161807</link>
      <description>&lt;P&gt;Okay. Actually this is a dataset after merge. Suppose all datas in this dataset should belong to KIND A, but some of them do not match&amp;nbsp; KIND A. I used a indicator to show if they are matched. But I also want to show 'the kind that these obs are supposed to belong to', cause I may stack datasets of different kinds.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;--Have--     
KIND  KIND_CD  var1    var2...    match
A     1         1                   1
A     1         2                   1
A     1         3                   1
.     .         4                   0
.     .         5&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;0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Hope this will be more clear&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:33:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573254#M161807</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-12T23:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573255#M161808</link>
      <description>&lt;P&gt;Please help my understanding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you looking to fill(LOCF) missings only the &lt;STRONG&gt;KIND:&lt;/STRONG&gt; group of variables ? or for &lt;STRONG&gt;var:&lt;/STRONG&gt; group as well?&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573255#M161808</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-12T23:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573256#M161809</link>
      <description>only KIND: group.&lt;BR /&gt;But in actual they do not have same prefix</description>
      <pubDate>Fri, 12 Jul 2019 23:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573256#M161809</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-12T23:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573257#M161810</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;But in actual they do not have same prefix"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Oh Well, that's the reason I requested a "&lt;U&gt;representative&lt;/U&gt;" sample&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:40:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573257#M161810</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-12T23:40:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573258#M161811</link>
      <description>&lt;P&gt;I'm sorry. I used the same prefix just hope it will be more easy to understand&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573258#M161811</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-12T23:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573259#M161812</link>
      <description>&lt;P&gt;If you could provide us a clean sample(mock is fine) with the correct set of var names assuming kind group belong to the same type, i can give it a shot.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 23:53:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573259#M161812</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-07-12T23:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573287#M161827</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input KIND $ KIND_CD  var1;
id=1;
cards; 
A     1         1    
A     .         2
A     1         3
.     1         4
.     1         5
;
run;
data want;
 update have(obs=0) have;
 by id;
 output;
 drop id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 13 Jul 2019 11:51:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/573287#M161827</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-13T11:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to keep the first value of a variable to other observations?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/574317#M162259</link>
      <description>&lt;P&gt;Thank you so much! It really helps!&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 18:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-keep-the-first-value-of-a-variable-to-other-observations/m-p/574317#M162259</guid>
      <dc:creator>Ada77</dc:creator>
      <dc:date>2019-07-17T18:24:04Z</dc:date>
    </item>
  </channel>
</rss>

