<?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 a column that has special chars in it's name for data manipulation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750862#M236254</link>
    <description>&lt;P&gt;I did not import the data, I created the dataset.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data;
	set info_raw;
	if &amp;lt;condition&amp;gt; then discount_grp = -1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 0;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1000;
.........
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After that I did some more manipulations and used the proc transpose procedure to create the have table and that seemed to work which is why I the columns got named that way&lt;/P&gt;
&lt;PRE&gt;proc transpose data=freq2 out=freq3 (DROP=_LABEL_ _NAME_ ) prefix=vol_;&lt;BR /&gt;by time_period;&lt;BR /&gt;id disc_grp;&lt;BR /&gt;var frequency;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
    <pubDate>Mon, 28 Jun 2021 17:14:24 GMT</pubDate>
    <dc:creator>aalluru</dc:creator>
    <dc:date>2021-06-28T17:14:24Z</dc:date>
    <item>
      <title>How to use a column that has special chars in it's name for data manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750852#M236250</link>
      <description>&lt;P&gt;I have a dataset (have) with columns named as follows: time_period, vol_-1, vol_0, vol_1, vol_1000.&lt;/P&gt;
&lt;P&gt;I want to create a column that calculates the sum of these values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
total_vol = sum(vol_-1, vol_0, vol_1, vol_1000);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, since vol_-1 has a special character in it, I am getting an error. How can I get around this problem?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 16:04:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750852#M236250</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2021-06-28T16:04:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a column that has special chars in it's name for data manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750854#M236252</link>
      <description>&lt;P&gt;1. Re-import your data after specifying the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options validvarname=v7;
...
import and rest of code;
...


total_vol = sum(vol__1, vol_0, vol_1, vol_1000);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will ensure that SAS imports the data with names that are easier to type - ie it will convert symbols to underscores so your variable will likely be vol__1 -&amp;gt; which could easily be mistaken with vol_1.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Use the name literal version to refer to a data set or variable name that has spaces or special characters.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;total_vol = sum('vol_-1'n, vol_0, vol_1, vol_1000);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a dataset (have) with columns named as follows: time_period, vol_-1, vol_0, vol_1, vol_1000.&lt;/P&gt;
&lt;P&gt;I want to create a column that calculates the sum of these values:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
total_vol = sum(vol_-1, vol_0, vol_1, vol_1000);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;However, since vol_-1 has a special character in it, I am getting an error. How can I get around this problem?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 16:11:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750854#M236252</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-28T16:11:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a column that has special chars in it's name for data manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750862#M236254</link>
      <description>&lt;P&gt;I did not import the data, I created the dataset.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data;
	set info_raw;
	if &amp;lt;condition&amp;gt; then discount_grp = -1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 0;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1000;
.........
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After that I did some more manipulations and used the proc transpose procedure to create the have table and that seemed to work which is why I the columns got named that way&lt;/P&gt;
&lt;PRE&gt;proc transpose data=freq2 out=freq3 (DROP=_LABEL_ _NAME_ ) prefix=vol_;&lt;BR /&gt;by time_period;&lt;BR /&gt;id disc_grp;&lt;BR /&gt;var frequency;&lt;BR /&gt;run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Jun 2021 17:14:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750862#M236254</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2021-06-28T17:14:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a column that has special chars in it's name for data manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750863#M236255</link>
      <description>&lt;P&gt;The concept is the same, did neither of the suggested options work for you?&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/355241"&gt;@aalluru&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I did not import the data, I created the dataset.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data data;
	set info_raw;
	if &amp;lt;condition&amp;gt; then discount_grp = -1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 0;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1;
	else if &amp;lt;condition&amp;gt; then discount_grp = 1000;
.........
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After that I did some more manipulations and used the proc transpose procedure to create the have table and that seemed to work which is why I the columns got named that way&lt;/P&gt;
&lt;PRE&gt;proc transpose data=freq2 out=freq3 (DROP=_LABEL_ _NAME_ ) prefix=vol_;&lt;BR /&gt;by time_period;&lt;BR /&gt;id disc_grp;&lt;BR /&gt;var frequency;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 17:20:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750863#M236255</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-06-28T17:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use a column that has special chars in it's name for data manipulation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750864#M236256</link>
      <description>&lt;P&gt;yes the second options worked well for mine. Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 17:24:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-a-column-that-has-special-chars-in-it-s-name-for-data/m-p/750864#M236256</guid>
      <dc:creator>aalluru</dc:creator>
      <dc:date>2021-06-28T17:24:45Z</dc:date>
    </item>
  </channel>
</rss>

