<?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: Dynamic Keep=() When Column Names have Spaces in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435465#M108202</link>
    <description>&lt;P&gt;Using similar logic I run into an issue with:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select '"'||name||'"n=' || '"'||colnameCopy ||'"n' into: renameString separated by " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from TestImportCols3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where year2 = '2016';&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; year2016; set work.combined (rename=&amp;amp;renameString);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;It looks like I am running into an error with the rename function using the same logic when I rename&lt;/P&gt;
&lt;P&gt;“Grand total men (C2016_B” to “M”&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if this is due to the way I have ' ' n setup in the renameString above.&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 21:59:15 GMT</pubDate>
    <dc:creator>DavidPhillips2</dc:creator>
    <dc:date>2018-02-08T21:59:15Z</dc:date>
    <item>
      <title>Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435415#M108184</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt; select name into :var_list&lt;BR /&gt; from TestImportCols3&lt;BR /&gt; where year2 = '2016';&lt;BR /&gt; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data year2016; set work.combined (keep=(&amp;amp;var_list));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Name contains values like:&lt;/P&gt;
&lt;P&gt;Grand total (C2016_B)&lt;/P&gt;
&lt;P&gt;that have spaces.&amp;nbsp; How can I include this in the keep list?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 20:14:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435415#M108184</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T20:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435419#M108185</link>
      <description>&lt;P&gt;The spaces are already included, just based on the code that you have shown.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, the question becomes how can you tell when one value of NAME ends and the next value begins?&amp;nbsp; To do that, you would need to insert a separator that doesn't appear in any of the NAME values.&amp;nbsp; For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select name into : var_list separated by '#'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Later, when you examine &amp;amp;VAR_LIST, you can expect that the occurrence of # separates one NAME from the next.&amp;nbsp; Inside a macro language program, you might have something along the lines of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do k=1 %to 5;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %let next_name = %scan(&amp;amp;var_list, &amp;amp;k, #) ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; %put &amp;amp;next_name;&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 20:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435419#M108185</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-02-08T20:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435420#M108186</link>
      <description>&lt;P&gt;convert to sas name literal using nliteral function&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then your keep should have no problems i think&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select nliteral(name) into :var_list separated by ' '
from TestImportCols3
where year2 = '2016';
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 08 Feb 2018 20:28:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435420#M108186</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-08T20:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435436#M108188</link>
      <description>&lt;P&gt;This is helpful but I’m running into a complication where some of the text contains names like master’s.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 20:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435436#M108188</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T20:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435439#M108189</link>
      <description>&lt;P&gt;Astounding, does this example keep particular columns? &amp;nbsp;I’m not following this logic.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:01:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435439#M108189</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T21:01:29Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435441#M108190</link>
      <description>&lt;P&gt;nliteral will comfortably take care of the embedded ' token in master's as it would convert into a text and wrap automatically with double quotes. The automatic tokenisation takes care of it particularly when master's is a value of variable coming from a dataset as i see in your example.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:04:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435441#M108190</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-08T21:04:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435443#M108191</link>
      <description>&lt;P&gt;I am researching&amp;nbsp;&lt;SPAN&gt;nliteral&lt;/SPAN&gt;, where do you use&amp;nbsp;&lt;SPAN&gt;nliteral?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:08:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435443#M108191</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T21:08:33Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435444#M108192</link>
      <description>&lt;P&gt;Ok basically when you are using variable names that do not conform to standard sas names, you may use the option of validvarname=any&amp;nbsp; .&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000998953.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;ANY&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;SAS variable names can be up to 32 characters in length.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The name can contain special and multi-byte characters not to exceed 32 bytes.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The name cannot contain any null bytes.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;A name can contain blanks. The leading blanks are preserved, but the trailing blanks are ignored.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;A name must contain at least one character. A name with all blanks is not permitted.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;The name can start with or contain any characters, including blanks.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Once the option is set, the use of nliteral function basically converts with the wrapper &lt;STRONG&gt;"blah blah"N &lt;/STRONG&gt;to make SAS understand it is deemed validvarname&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:13:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435444#M108192</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-02-08T21:13:18Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435445#M108193</link>
      <description>&lt;P&gt;Try this if you don't want to change the variable names into sas naming convention.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;select '"'||var||'"n' into:vars separated by " "&lt;BR /&gt;from test;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:16:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435445#M108193</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-02-08T21:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435449#M108195</link>
      <description>&lt;P&gt;This worked:&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt; select '"'||name||'"n' into:var_list separated by " "&lt;BR /&gt; from TestImportCols3&lt;BR /&gt; where year2 = '2016';&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data year2016; set work.combined (keep=&amp;amp;var_list);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435449#M108195</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T21:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435465#M108202</link>
      <description>&lt;P&gt;Using similar logic I run into an issue with:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select '"'||name||'"n=' || '"'||colnameCopy ||'"n' into: renameString separated by " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from TestImportCols3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where year2 = '2016';&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data&lt;/STRONG&gt; year2016; set work.combined (rename=&amp;amp;renameString);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;It looks like I am running into an error with the rename function using the same logic when I rename&lt;/P&gt;
&lt;P&gt;“Grand total men (C2016_B” to “M”&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure if this is due to the way I have ' ' n setup in the renameString above.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 21:59:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435465#M108202</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-08T21:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435495#M108204</link>
      <description>&lt;P&gt;Take a very close look at the results of&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sql&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select '"'||name||'"n=' || '"'||colnameCopy ||'"n' into: renameString separated by " "&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from TestImportCols3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where year2 = '2016';&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look to see if any of the elements have spaces that you do not expect for the Name or colnamecopy variables. The || concatenation operator usually pads the result with blanks to format length. See&lt;/P&gt;
&lt;PRE&gt;data junk;
   informat name $15.;
   input name;
datalines;
Fred
John
Somethinglong
;
run;

proc sql;
   select '"'||name||'"n=' into : string separated by ' '
   from junk;
run;
%put &amp;amp;string;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try || strip(variablename)|| when using the || concatenation.&lt;/P&gt;
&lt;P&gt;Or&lt;/P&gt;
&lt;P&gt;select cats('"',name,'"n=','"',colnamecopy,'"n') into&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 23:30:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435495#M108204</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-08T23:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435647#M108244</link>
      <description>&lt;P&gt;The strip function seems to have made progress.&amp;nbsp; I'm running into an error on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Grand total women (C2016_B)"n="Wn"n&lt;/P&gt;
&lt;P&gt;ERROR 22-7: Invalid option name "Grand total women (C2016_B)"N.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently playing with table 'junk' to see if I can recreate the error on a non-big data set.&amp;nbsp; I'm working with 3000 columns.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 14:17:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435647#M108244</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-09T14:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435652#M108245</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt; create table TestImportCols3 (&lt;BR /&gt; name varchar(30),&lt;BR /&gt; colnameCopy varchar(30)&lt;BR /&gt; );&lt;/P&gt;
&lt;P&gt;insert into TestImportCols3 ( name, colnameCopy) values ('Grand total women (C2016_B)', 'Wn'); &lt;BR /&gt; insert into TestImportCols3 ( name, colnameCopy) values ('Master''s', 'M');&lt;/P&gt;
&lt;P&gt;create table combined (&lt;BR /&gt; b varchar(30)&lt;BR /&gt; );&lt;BR /&gt; &lt;BR /&gt; insert into combined (b) values ('fifkgj');&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data combined; set combined (rename=(b ="Grand total women (C2016_B)"n));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt; select '"'|| strip(name) ||'"n=' || '"'|| strip(colnameCopy) ||'"n' into: renameString separated by " "&lt;BR /&gt; from TestImportCols3;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data year2016; set work.combined (rename=&amp;amp;renameString);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;produces:&lt;/P&gt;
&lt;P&gt;48 "Grand total women (C2016_B)"n="Wn"n "Master's"n="M"n&lt;BR /&gt; ___________&lt;BR /&gt; 22&lt;BR /&gt;ERROR 22-7: Invalid option name "Master's"N.&lt;/P&gt;
&lt;P&gt;Due to the '&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 15:06:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435652#M108245</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-09T15:06:57Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435682#M108253</link>
      <description>&lt;P&gt;Its not the ' that is causing the error its the second record.&amp;nbsp; Taking the ' out results in the same thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;create table TestImportCols3 (&lt;BR /&gt;name varchar(30),&lt;BR /&gt;colnameCopy varchar(30)&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;insert into TestImportCols3 ( name, colnameCopy) values ('Grand total women (C2016_B)', 'Wn'); &lt;BR /&gt;insert into TestImportCols3 ( name, colnameCopy) values ('Masters', 'M');&lt;/P&gt;
&lt;P&gt;create table combined (&lt;BR /&gt;b varchar(30)&lt;BR /&gt;);&lt;/P&gt;
&lt;P&gt;insert into combined (b) values ('fifkgj');&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data combined; set combined (rename=(b ="Grand total women (C2016_B)"n));&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select '"'|| strip(name) ||'"n=' || '"'|| strip(colnameCopy) ||'"n' into: renameString separated by " "&lt;BR /&gt;from TestImportCols3;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;data year2016; set work.combined (rename=&amp;amp;renameString);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;47 "Grand total women (C2016_B)"n="Wn"n "Masters"n="M"n&lt;BR /&gt; __________&lt;BR /&gt; 22&lt;BR /&gt;ERROR 22-7: Invalid option name "Masters"N.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;This has the same error:&lt;/P&gt;
&lt;P&gt;data year2016; set work.combined (rename="Grand total women (C2016_B)"n="Wn"n Masters=M);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 16:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435682#M108253</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-09T16:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435697#M108259</link>
      <description>&lt;P&gt;data year2016; set work.combined (rename=(&amp;amp;renameString));&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was missing a set of ()&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 16:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435697#M108259</guid>
      <dc:creator>DavidPhillips2</dc:creator>
      <dc:date>2018-02-09T16:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic Keep=() When Column Names have Spaces</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435704#M108263</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5059"&gt;@DavidPhillips2&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;The strip function seems to have made progress.&amp;nbsp; I'm running into an error on:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Grand total women (C2016_B)"n="Wn"n&lt;/P&gt;
&lt;P&gt;ERROR 22-7: Invalid option name "Grand total women (C2016_B)"N.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am currently playing with table 'junk' to see if I can recreate the error on a non-big data set.&amp;nbsp; I'm working with 3000 columns.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Testing renaming can actually be done with a very small data set. You don't even need any observations unless you also want to do something like changing formats:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data testset;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set bigset (obs=1);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;Or obs =0 if you don't need to see actual values.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2018 16:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-Keep-When-Column-Names-have-Spaces/m-p/435704#M108263</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-02-09T16:54:16Z</dc:date>
    </item>
  </channel>
</rss>

