<?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 use drop and rename in the data statement at one time in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343557#M63400</link>
    <description>&lt;P&gt;A little reformatting of your DATA statement will probably make the error more obvious.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data 
  round (drop=var1 var2)
  rename= (pctvar1=var1 pctvar2=var2)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have one output dataset name ROUND with the DROP= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Then it looks like you are starting to also define another output dataset named RENAME, but you added an extra = sign after the data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So fixing the nesting of your () so that you have just one output dataset you get this syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data round 
 (drop=var1 var2
  rename= (pctvar1=var1 pctvar2=var2)
 )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It probably is easier to type if you just use the DROP and RENAME statements instead of adding dataset options to the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data round ;
  set .... ;
  ....
  drop var1 var2;
  rename pctvar1=var1 pctvar2=var2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 Mar 2017 01:14:10 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-03-23T01:14:10Z</dc:date>
    <item>
      <title>How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343535#M63398</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to drop variables and rename variables in a dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have var1 and var2 in the orignal dataset and am converting them into percentages using arrays.&amp;nbsp; I'd like&amp;nbsp;the&amp;nbsp;variables in the&amp;nbsp;output dataset to have the&amp;nbsp;&amp;nbsp;same names var1 and var2 so I'm trying to rename the new variables I created (pctvar1 pctvar2) to become var1 and var2 and also drop the old var1 and var2 variables that I don't need.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; round (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=var1 var2) &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;rename&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;= (pctvar1=var1 pctvar2=var2);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; first;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#008000" face="Courier New" size="2"&gt;*create percentages;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; mult var1 var2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pct pctvar1 pctvar2;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;over&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; mult&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;pct=mult*&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;100&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*--round to nearest tenth;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;do&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;over&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; pct;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;pct=round(pct, &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;.1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;What am I doing wrong?&amp;nbsp; thanks!&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Mar 2017 23:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343535#M63398</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-03-22T23:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343536#M63399</link>
      <description>&lt;P&gt;Ignore my stupid calculations, but it looks like you want to do the following, in which case it's just a matter of getting your parentheses correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first;
    var1 = 1;
    var2 = 1;
run;

data round(drop = var1 var2 rename= (pctvar1=var1 pctvar2=var2));
    set first;
    pctVar1 = var1 / 10;
    pctVar2 = var2 / 10;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Mar 2017 23:50:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343536#M63399</guid>
      <dc:creator>collinelliot</dc:creator>
      <dc:date>2017-03-22T23:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343557#M63400</link>
      <description>&lt;P&gt;A little reformatting of your DATA statement will probably make the error more obvious.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data 
  round (drop=var1 var2)
  rename= (pctvar1=var1 pctvar2=var2)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You have one output dataset name ROUND with the DROP= dataset option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Then it looks like you are starting to also define another output dataset named RENAME, but you added an extra = sign after the data set name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So fixing the nesting of your () so that you have just one output dataset you get this syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data round 
 (drop=var1 var2
  rename= (pctvar1=var1 pctvar2=var2)
 )
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It probably is easier to type if you just use the DROP and RENAME statements instead of adding dataset options to the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data round ;
  set .... ;
  ....
  drop var1 var2;
  rename pctvar1=var1 pctvar2=var2;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 Mar 2017 01:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343557#M63400</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-23T01:14:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343559#M63401</link>
      <description>&lt;P&gt;Thank you both!&amp;nbsp; Super helpful!!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2017 01:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/343559#M63401</guid>
      <dc:creator>jcis7</dc:creator>
      <dc:date>2017-03-23T01:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/647072#M78597</link>
      <description>&lt;P&gt;data first;&lt;BR /&gt;var1 = 1;&lt;BR /&gt;var2 = 1;&lt;BR /&gt;var3= 3;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;data round (drop=var3 rename=(var1=pctvar1 var2=pctvar2));&lt;BR /&gt;set first ;&lt;BR /&gt;Var1 = var1 / 10;&lt;BR /&gt;Var2 = var2 / 10;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you dont need drop the variable its been already renamed&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 12:40:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/647072#M78597</guid>
      <dc:creator>vidyapedii</dc:creator>
      <dc:date>2020-05-12T12:40:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/781379#M81229</link>
      <description>What is the order of operations here? Doesn't this syntax drop variables that were renamed? &lt;BR /&gt;What syntax would allow you to drop the original variables after renaming them? In other words, pctvar1 gets renamed to  var1, pctvar2 gets renamed to var2 and then pctvar1 and pctvar1 get dropped.</description>
      <pubDate>Fri, 19 Nov 2021 20:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/781379#M81229</guid>
      <dc:creator>_maldini_</dc:creator>
      <dc:date>2021-11-19T20:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use drop and rename in the data statement at one time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/781415#M81230</link>
      <description>&lt;P&gt;Dataset options are processed in the alphabetical order:&lt;/P&gt;
&lt;P&gt;Drop=/Keep= first&lt;/P&gt;
&lt;P&gt;Rename= second&lt;/P&gt;
&lt;P&gt;Where= last&lt;/P&gt;</description>
      <pubDate>Fri, 19 Nov 2021 22:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-use-drop-and-rename-in-the-data-statement-at-one-time/m-p/781415#M81230</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-19T22:42:17Z</dc:date>
    </item>
  </channel>
</rss>

