<?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 fill with repetitive value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391151#M93905</link>
    <description>&lt;P&gt;This should do the trick&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," missover truncover;
	length state $2 name $6;
	input state $ name $;
	datalines;
NY,Joy
   ,Thomas
   ,Mike
TX,Albert
   ,James
IL,Corey
;
run;

data want(drop=holdstate);
	length state2 $2;
	set have;
	if _n_=1 then do;
		holdstate=state;
		state2=state;
	end;
	else do;
		if state="" then state2=holdstate;
		else do;
			holdstate=state;
			state2=state;
		end;
	end;
	retain holdstate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 27 Aug 2017 21:33:28 GMT</pubDate>
    <dc:creator>ChrisBrooks</dc:creator>
    <dc:date>2017-08-27T21:33:28Z</dc:date>
    <item>
      <title>How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391148#M93903</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I am trying to fill the below cells with repetitive value. Can someone help me please&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;My Table (&lt;/STRONG&gt;table name is&amp;nbsp;have&lt;STRONG&gt;)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;State &amp;nbsp;Name&lt;/P&gt;
&lt;P&gt;NY &amp;nbsp; &amp;nbsp; Joy&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thomas&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mike&lt;/P&gt;
&lt;P&gt;TX &amp;nbsp; &amp;nbsp; Albert&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;James&lt;/P&gt;
&lt;P&gt;IL &amp;nbsp; &amp;nbsp; &amp;nbsp;Corey&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Output Table &lt;/STRONG&gt;(Table name is&amp;nbsp;want)&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;State &amp;nbsp;Name &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;STATE2&lt;/P&gt;
&lt;P&gt;NY &amp;nbsp; &amp;nbsp; Joy &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NY&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Thomas &amp;nbsp; &amp;nbsp; &amp;nbsp;NY&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Mike &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; NY&lt;/P&gt;
&lt;P&gt;TX &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Albert &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TX&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;James &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TX&lt;/P&gt;
&lt;P&gt;IL &amp;nbsp; &amp;nbsp; &amp;nbsp;Corey &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IL&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 21:07:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391148#M93903</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2017-08-27T21:07:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391150#M93904</link>
      <description>&lt;P&gt;Here is one way:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  retain state2;
  if not missing(state) then state2=state;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 21:33:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391150#M93904</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-08-27T21:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391151#M93905</link>
      <description>&lt;P&gt;This should do the trick&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	infile datalines dlm="," missover truncover;
	length state $2 name $6;
	input state $ name $;
	datalines;
NY,Joy
   ,Thomas
   ,Mike
TX,Albert
   ,James
IL,Corey
;
run;

data want(drop=holdstate);
	length state2 $2;
	set have;
	if _n_=1 then do;
		holdstate=state;
		state2=state;
	end;
	else do;
		if state="" then state2=holdstate;
		else do;
			holdstate=state;
			state2=state;
		end;
	end;
	retain holdstate;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Aug 2017 21:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391151#M93905</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-08-27T21:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391164#M93911</link>
      <description>Hi art297, Your code just copy the column STATE to STATE2. Would you please verify. Remember that STATE2 variable did not exist in the have database.&lt;BR /&gt;&lt;BR /&gt;Thanks,</description>
      <pubDate>Sun, 27 Aug 2017 23:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391164#M93911</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2017-08-27T23:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391165#M93912</link>
      <description>&lt;P&gt;Run the code on your data. It does what I think you requested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 23:46:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391165#M93912</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-08-27T23:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to fill with repetitive value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391167#M93914</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt; wrote:&lt;BR /&gt;Hi art297, Your code just copy the column STATE to STATE2.&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No it doesn't.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code is:&lt;/P&gt;
&lt;PRE&gt;data want;
  set have;
  retain state2;
  if not missing(state) then state2=state;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;RETAIN holds the value until it is changed explicitly.&lt;/P&gt;
&lt;P&gt;The assignment of State to STATE2 only occurs when there is a new value of STATE. &amp;nbsp;It returns exactly your desired stated output using the simplest methods.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it isn't doing what you want, you need to provide more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 00:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-fill-with-repetitive-value/m-p/391167#M93914</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-28T00:05:56Z</dc:date>
    </item>
  </channel>
</rss>

