<?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 Copy data of one variable to another with missing data in it. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596575#M171789</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294186"&gt;@Rakesh93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RFS TFTC=RFXSTDTC;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have an unnecessary (and wrong) space in the code. You want RFSTFTC without a space:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DM6;
   set DM5;
   RFSTFTC=RFXSTDTC;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Editor's Note:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Special thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;for sharing how to conditionally assign a value if the original variable is missing using the COALESCE function for numeric values, and the COALESCEC function for character values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   Num_1=.;
   Var_1='    ';
   Var_2='    ';
	NUM_A=10;
	VAR_A='Test';
	put 'NOTE: Before ***********************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
	NUM_1=coalesce(NUM_1, NUM_A);
	VAR_1=coalescec(VAR_1, VAR_A);
	put 'NOTE: After first *******************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
	NUM_2=coalesce(NUM_1, NUM_A);
	VAR_2=coalescec(VAR_1, VAR_A);
	put 'NOTE: After last *******************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Before ***********************
NOTE: Num_1=. NUM_2=. NUM_A=10
      Var_1=  Var_2=  VAR_A=Test

NOTE: After first *******************
NOTE: Num_1=10 NUM_2=. NUM_A=10
      Var_1=Test Var_2=  VAR_A=Test

NOTE: After last *******************
NOTE: Num_1=10 NUM_2=10 NUM_A=10
      Var_1=Test Var_2=Test VAR_A=Test
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 29 Jul 2022 19:47:02 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-07-29T19:47:02Z</dc:date>
    <item>
      <title>How to Copy data of one variable to another with missing data in it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596574#M171788</link>
      <description>How to copy data of one variable to another in SAS.&lt;BR /&gt;I was using this program&lt;BR /&gt;Data DM6;&lt;BR /&gt;Set DM5;&lt;BR /&gt;RFS TFTC=RFXSTDTC;&lt;BR /&gt;Run;</description>
      <pubDate>Tue, 15 Oct 2019 15:54:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596574#M171788</guid>
      <dc:creator>Rakesh93</dc:creator>
      <dc:date>2019-10-15T15:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to Copy data of one variable to another with missing data in it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596575#M171789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/294186"&gt;@Rakesh93&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;RFS TFTC=RFXSTDTC;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You have an unnecessary (and wrong) space in the code. You want RFSTFTC without a space:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DM6;
   set DM5;
   RFSTFTC=RFXSTDTC;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;Editor's Note:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Special thanks to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/21262"&gt;@hashman&lt;/a&gt;&amp;nbsp;for sharing how to conditionally assign a value if the original variable is missing using the COALESCE function for numeric values, and the COALESCEC function for character values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   Num_1=.;
   Var_1='    ';
   Var_2='    ';
	NUM_A=10;
	VAR_A='Test';
	put 'NOTE: Before ***********************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
	NUM_1=coalesce(NUM_1, NUM_A);
	VAR_1=coalescec(VAR_1, VAR_A);
	put 'NOTE: After first *******************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
	NUM_2=coalesce(NUM_1, NUM_A);
	VAR_2=coalescec(VAR_1, VAR_A);
	put 'NOTE: After last *******************';
	put 'NOTE: ' NUM_1= NUM_2= NUM_A=;
	put 'NOTE- ' VAR_1= VAR_2= VAR_A=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And the result:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Before ***********************
NOTE: Num_1=. NUM_2=. NUM_A=10
      Var_1=  Var_2=  VAR_A=Test

NOTE: After first *******************
NOTE: Num_1=10 NUM_2=. NUM_A=10
      Var_1=Test Var_2=  VAR_A=Test

NOTE: After last *******************
NOTE: Num_1=10 NUM_2=10 NUM_A=10
      Var_1=Test Var_2=Test VAR_A=Test
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jul 2022 19:47:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596575#M171789</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-07-29T19:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to Copy data of one variable to another with missing data in it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596584#M171793</link>
      <description>&lt;P&gt;Lets say there are two variables VAR1 and VAR2. VAR2 have some missing values and you want to fill the missing values with values from VAR1.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data NEW;&lt;/P&gt;&lt;P&gt;set Sorucedataset;&lt;/P&gt;&lt;P&gt;If Var2=" " then&amp;nbsp; VAR2=VAR1;else VAR2=VAR2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Oct 2019 16:17:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596584#M171793</guid>
      <dc:creator>ravig</dc:creator>
      <dc:date>2019-10-15T16:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to Copy data of one variable to another with missing data in it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596676#M171839</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;RFSTFTC=coalesce(RFSTFTC,RFXSTDTC)&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;for a numeric variable.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 02:26:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596676#M171839</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-16T02:26:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to Copy data of one variable to another with missing data in it.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596702#M171851</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/175836"&gt;@ravig&lt;/a&gt;: Heed what&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;has said.&lt;/P&gt;
&lt;P&gt;If your variables are character, use the COALESCE&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;C&lt;/STRONG&gt;&lt;/FONT&gt; function instead.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to make you code data type insensitive, use SQL where the single COALESCE function is good for both numeric or character variables, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
  create table want as select coalesce (var1, var2) as var2 from have ;
quit ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 00:34:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Copy-data-of-one-variable-to-another-with-missing-data-in/m-p/596702#M171851</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-16T00:34:56Z</dc:date>
    </item>
  </channel>
</rss>

