<?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: Keep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783300#M249731</link>
    <description>That worked! I added ‘n’ as you suggested.&lt;BR /&gt;Thank you so much!&lt;BR /&gt;</description>
    <pubDate>Tue, 30 Nov 2021 22:51:20 GMT</pubDate>
    <dc:creator>AJ_Brien</dc:creator>
    <dc:date>2021-11-30T22:51:20Z</dc:date>
    <item>
      <title>Keep= macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783278#M249716</link>
      <description>Hello mentors,&lt;BR /&gt;&lt;BR /&gt;I have a base dataset that has the following columns: _name_, 201902, 201903............202110.&lt;BR /&gt;I’m looking to extract the 1st and last columns, so I defined a macro variable:&lt;BR /&gt;%let yyyymm= %sysfunc(intnx(month,%sysfunc(date()),-1,s, yymmn6.);&lt;BR /&gt;Which gives me the value 202110.&lt;BR /&gt;&lt;BR /&gt;So now i try to create a dataset:&lt;BR /&gt;Data want (keep= _name_ &amp;amp;yyyymm.);&lt;BR /&gt;Set have;&lt;BR /&gt;Run;&lt;BR /&gt;&lt;BR /&gt;This keeps giving me errors:&lt;BR /&gt;Variable name “202110” is not valid.&lt;BR /&gt;Invalid value for the keep option.&lt;BR /&gt;&lt;BR /&gt;I even did proc contents for ‘have’ dataset, and 202110 is a valid variable in there.&lt;BR /&gt;What am I doing wrong?&lt;BR /&gt;&lt;BR /&gt;Thank you for all the help!</description>
      <pubDate>Tue, 30 Nov 2021 21:14:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783278#M249716</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2021-11-30T21:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Keep= macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783283#M249718</link>
      <description>&lt;P&gt;There are rules that determine what names are allowed. Normally, a variable name of 202110 is not allowed (and really is a bad idea to have calendar information in variable names anyway).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either you are seeing the variable label when you look at the data set (are you?) or the data set was created with&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=any;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in which case you can refer to a variable name as '202110'n (note the quotes and the suffix which is the letter n) and so you can refer to it as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data want (keep= _name_ "&amp;amp;yyyymm"n);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Do yourself a favor and turn this data set into a long data set (instead of a wide data set) where the month is the value of the variable named MONTH, and then almost all of your programming becomes much much much much much much much much easier muchly.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 21:22:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783283#M249718</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-30T21:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Keep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783300#M249731</link>
      <description>That worked! I added ‘n’ as you suggested.&lt;BR /&gt;Thank you so much!&lt;BR /&gt;</description>
      <pubDate>Tue, 30 Nov 2021 22:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783300#M249731</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2021-11-30T22:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Keep= macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783301#M249732</link>
      <description>Someone else is creating the base dataset so I couldn’t update the variable names. But adding ‘n’ After the variable name totally worked. Thank you so much!</description>
      <pubDate>Tue, 30 Nov 2021 22:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783301#M249732</guid>
      <dc:creator>AJ_Brien</dc:creator>
      <dc:date>2021-11-30T22:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Keep= macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783368#M249762</link>
      <description>&lt;P&gt;Let me correct something you said.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265086"&gt;@AJ_Brien&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Someone else is creating the base dataset so I couldn’t update the variable names. But adding ‘n’ After the variable name totally worked.&amp;nbsp;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;you don't add 'n' with quotes&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you put the variable names in quotes and then append the letter n&lt;/P&gt;</description>
      <pubDate>Wed, 01 Dec 2021 11:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-macro-variables/m-p/783368#M249762</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-12-01T11:05:30Z</dc:date>
    </item>
  </channel>
</rss>

