<?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: Is this possible in sas? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16883#M3151</link>
    <description>You could also do it with the KEEP= or DROP= option on the DATA statement.</description>
    <pubDate>Thu, 14 Oct 2010 13:25:58 GMT</pubDate>
    <dc:creator>Doc_Duke</dc:creator>
    <dc:date>2010-10-14T13:25:58Z</dc:date>
    <item>
      <title>Is this possible in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16881#M3149</link>
      <description>Hello.&lt;BR /&gt;
&lt;BR /&gt;
I am supposed to find out if this is possible:&lt;BR /&gt;
&lt;BR /&gt;
DATA FILE1 FILE2;&lt;BR /&gt;
SET FILE_IN;&lt;BR /&gt;
&lt;BR /&gt;
IF X=Y THEN DO;&lt;BR /&gt;
NEWVAR1=VAR1;&lt;BR /&gt;
OUTPUT FILE1;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
ELSE DO;&lt;BR /&gt;
NEWVAR2=VAR1;&lt;BR /&gt;
OUTPUT FILE2;&lt;BR /&gt;
END;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Is it somehow possible that SAS with the help of some keyword only have newvar1 in file1 in addition to all other variables. And in file2 its only consist all variables + newvar2. &lt;BR /&gt;
&lt;BR /&gt;
This is very simple with drop and keep. But is it possible without, make sas execute partly?  May be this is to make it more difficult. But I just want to know if its possible in other way or not. I cannot figure out another way than using drop and keep.   &lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Thu, 14 Oct 2010 08:58:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16881#M3149</guid>
      <dc:creator>nidhi123</dc:creator>
      <dc:date>2010-10-14T08:58:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is this possible in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16882#M3150</link>
      <description>See the documentation for the RENAME dataset option.</description>
      <pubDate>Thu, 14 Oct 2010 09:20:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16882#M3150</guid>
      <dc:creator>Robert_Bardos</dc:creator>
      <dc:date>2010-10-14T09:20:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is this possible in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16883#M3151</link>
      <description>You could also do it with the KEEP= or DROP= option on the DATA statement.</description>
      <pubDate>Thu, 14 Oct 2010 13:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16883#M3151</guid>
      <dc:creator>Doc_Duke</dc:creator>
      <dc:date>2010-10-14T13:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is this possible in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16884#M3152</link>
      <description>Hi,&lt;BR /&gt;
&lt;BR /&gt;
data file1 file2;&lt;BR /&gt;
  set file_in;&lt;BR /&gt;
  if x=y then output file1;&lt;BR /&gt;
  else output file2;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc datasets library=work;&lt;BR /&gt;
  modify file1;&lt;BR /&gt;
  rename var1=newvar1;&lt;BR /&gt;
quit;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc dataset library=work;&lt;BR /&gt;
  modify file2;&lt;BR /&gt;
  rename var1=newvar2;&lt;BR /&gt;
quit;&lt;BR /&gt;
run;&lt;BR /&gt;
  &lt;BR /&gt;
Rename will give unwanted result if it is used within IF condition.  Rename is a global statement.   It creates the variable irrespective of the conditons checked.  &lt;BR /&gt;
Hence a seperate program for renaming. &lt;BR /&gt;
&lt;BR /&gt;
Sandhya.</description>
      <pubDate>Thu, 14 Oct 2010 14:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16884#M3152</guid>
      <dc:creator>Sandhya</dc:creator>
      <dc:date>2010-10-14T14:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Is this possible in sas?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16885#M3153</link>
      <description>It is a good and efficient practice to use proc datasets to rename variables, since this will just modify the header portion of the dataset.&lt;BR /&gt;
&lt;BR /&gt;
Sometimes, however, the data set options can be quite handy as well.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
   /* test data */&lt;BR /&gt;
   data one;&lt;BR /&gt;
     x=1; y=1; var1=1; output;&lt;BR /&gt;
     x=2; y=3; var1=2; output;&lt;BR /&gt;
     x=3; y=2; var1=3; output;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   /* separate and rename */&lt;BR /&gt;
   data two(rename=(var1=newvar1))&lt;BR /&gt;
        three(rename=(var1=newvar2));&lt;BR /&gt;
     set one;&lt;BR /&gt;
     if x=y then output two;&lt;BR /&gt;
     else output three;&lt;BR /&gt;
   run;&lt;BR /&gt;
&lt;BR /&gt;
   /* check */&lt;BR /&gt;
   proc print data=two;&lt;BR /&gt;
   run;&lt;BR /&gt;
   proc print data=three;&lt;BR /&gt;
   run;&lt;BR /&gt;
   /* on lst&lt;BR /&gt;
   Obs    x    y    newvar1&lt;BR /&gt;
&lt;BR /&gt;
    1     1    1       1&lt;BR /&gt;
&lt;BR /&gt;
   Obs    x    y    newvar2&lt;BR /&gt;
    1     2    3       2&lt;BR /&gt;
    2     3    2       3&lt;BR /&gt;
   */&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 14 Oct 2010 20:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Is-this-possible-in-sas/m-p/16885#M3153</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2010-10-14T20:10:00Z</dc:date>
    </item>
  </channel>
</rss>

