<?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 rename /keep statement question in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653395#M22506</link>
    <description>&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Hello all, I try to rename a variable and then keep only several variables in the dataset, but I meet some problem, can anyone help me with the following code and tell me what went wrong, thank you so much!&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.Dietaryday1_4yr;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.dr1iff_c&lt;SPAN&gt;&amp;nbsp;(rename=(DR1DAY=DR1DAY_IFF))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;nh.dr1iff_d (&lt;SPAN&gt;rename&lt;/SPAN&gt;=(DR1DAY=DR1DAY_IFF));&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.Dietaryday1_4yr;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.dr1iff_c (&lt;SPAN&gt;keep&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=seqn dr1ikcal DR1DAY_IFF )&lt;/P&gt;&lt;P&gt;nh.dr1iff_d (&lt;SPAN&gt;keep&lt;/SPAN&gt;=seqn dr1ikcal DR1DAY_IFF);&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The variable DR1DAY_IFF in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 18:54:30 GMT</pubDate>
    <dc:creator>knighsson</dc:creator>
    <dc:date>2020-06-04T18:54:30Z</dc:date>
    <item>
      <title>rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653395#M22506</link>
      <description>&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;Hello all, I try to rename a variable and then keep only several variables in the dataset, but I meet some problem, can anyone help me with the following code and tell me what went wrong, thank you so much!&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.Dietaryday1_4yr;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.dr1iff_c&lt;SPAN&gt;&amp;nbsp;(rename=(DR1DAY=DR1DAY_IFF))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;nh.dr1iff_d (&lt;SPAN&gt;rename&lt;/SPAN&gt;=(DR1DAY=DR1DAY_IFF));&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;SPAN&gt;;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.Dietaryday1_4yr;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;nh.dr1iff_c (&lt;SPAN&gt;keep&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=seqn dr1ikcal DR1DAY_IFF )&lt;/P&gt;&lt;P&gt;nh.dr1iff_d (&lt;SPAN&gt;keep&lt;/SPAN&gt;=seqn dr1ikcal DR1DAY_IFF);&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;RUN&lt;/STRONG&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: The variable DR1DAY_IFF in the DROP, KEEP, or RENAME list has never been referenced.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 18:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653395#M22506</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-06-04T18:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653402#M22507</link>
      <description>&lt;P&gt;I can only guess what you are trying to do, but I think it could be:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nh.Dietaryday1_4yr;
set 
	nh.dr1iff_c (keep =seqn dr1ikcal DR1DAY rename=(DR1DAY=DR1DAY_IFF))
	nh.dr1iff_d (keep =seqn dr1ikcal DR1DAY rename=(DR1DAY=DR1DAY_IFF));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:11:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653402#M22507</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-06-04T19:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653403#M22508</link>
      <description>&lt;P&gt;You code doesn't work because you are not changing the names of the variables in data set&amp;nbsp;&lt;SPAN&gt;nh.dr1iff_c. You are only changing the names of the variables in data set&amp;nbsp;nh.dr1iff_c when it is used to create&amp;nbsp;nh.Dietaryday1_4yr, and the names the next time you use nh.dr1iff_c are not renamed. So in your second data set, the names are the original variable names in&amp;nbsp;nh.dr1iff_c&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nh.Dietaryday1_4yr;
set nh.dr1iff_c (rename=(DR1DAY=DR1DAY_IFF) keep=dr1day seqn dr1ikcal)
    nh.dr1iff_d (rename=(DR1DAY=DR1DAY_IFF) keep=dr1day seqn dr1ikcal);
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:13:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653403#M22508</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-04T19:13:35Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653406#M22509</link>
      <description>&lt;P&gt;It might be clearer to use the RENAME and KEEP statements instead of the RENAME= and KEEP= dataset options.&amp;nbsp; Especially because you are doing the same rename and keep for both input datasets.&amp;nbsp; Note that this way during the data step&amp;nbsp;DR1DAY is the name to use. The RENAME statement impacts what name is used in the output dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data nh.Dietaryday1_4yr;
  set nh.dr1iff_c nh.dr1iff_d;
  keep seqn dr1ikcal DR1DAY;
  rename DR1DAY=DR1DAY_IFF ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:22:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653406#M22509</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-04T19:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653414#M22510</link>
      <description>&lt;P&gt;That makes sense!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653414#M22510</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-06-04T19:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653415#M22511</link>
      <description>Thank you!</description>
      <pubDate>Thu, 04 Jun 2020 19:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653415#M22511</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-06-04T19:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653418#M22512</link>
      <description>&lt;P&gt;What is happening if this is the actual code you submit is that you create the nh.Dietaryday1_4yr&lt;/P&gt;
&lt;PRE&gt;data nh.Dietaryday1_4yr;
set nh.dr1iff_c (rename=(DR1DAY=DR1DAY_IFF))
nh.dr1iff_d (rename=(DR1DAY=DR1DAY_IFF));
run; &lt;/PRE&gt;
&lt;P&gt;The you submit&lt;/P&gt;
&lt;PRE&gt;data nh.Dietaryday1_4yr;
set nh.dr1iff_c (keep =seqn dr1ikcal DR1DAY_IFF )
nh.dr1iff_d (keep=seqn dr1ikcal DR1DAY_IFF); 
RUN;&lt;/PRE&gt;
&lt;P&gt;Which recreates the data set from scratch. You did not rename the variable in the nh.dr1iff_c data set so you get the error.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/653418#M22512</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-04T19:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/663164#M22753</link>
      <description>Thank you!&lt;BR /&gt;</description>
      <pubDate>Thu, 18 Jun 2020 13:40:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/663164#M22753</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-06-18T13:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: rename /keep statement question</title>
      <link>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/663165#M22754</link>
      <description>Thank you!</description>
      <pubDate>Thu, 18 Jun 2020 13:41:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/rename-keep-statement-question/m-p/663165#M22754</guid>
      <dc:creator>knighsson</dc:creator>
      <dc:date>2020-06-18T13:41:10Z</dc:date>
    </item>
  </channel>
</rss>

