<?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: Data types error when using &amp;quot;select into&amp;quot; for a character variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819574#M34743</link>
    <description>&lt;P&gt;Anytime.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose charvar1 contains the values 'a', 'b' and 'c. Your code creates the macro variable a,b,c. However, SAS interprets a as a variable name and 'a' as a character value. You want SAS to interpret as character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Jun 2022 11:10:24 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2022-06-22T11:10:24Z</dc:date>
    <item>
      <title>Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819567#M34738</link>
      <description>&lt;P&gt;Hi SAS Community,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I am using the following code to pull make a list and lookup another dataset with this list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
select distinct charvar1 into :cvv1 separated by "," from dataset1;
quit;

proc sql; 
create table output1 as 
select *
from dataset2
where charvar1 in (&amp;amp;cv1);
quit;&lt;/PRE&gt;
&lt;P&gt;but I get the following error:&lt;/P&gt;
&lt;PRE&gt;ERROR: Expression using IN has components that are of different
       data types.
NOTE: The IN referred to may have been transformed from an OR to
      an IN at some point during PROC SQL WHERE clause
      optimization.&lt;/PRE&gt;
&lt;P&gt;I have checked the charvar1 and in both dataset1 and dataset2 it has the format&amp;nbsp;$16. so I don't understand why it is saying that they are different types. Any help would be really great!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 10:58:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819567#M34738</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-06-22T10:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819571#M34740</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   select distinct quote(strip(charvar1)) 
   into :cvv1 separated by "," 
   from dataset1;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:05:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819571#M34740</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-06-22T11:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819573#M34742</link>
      <description>Thank you Peter. Why did the original not work and why does you fix work?</description>
      <pubDate>Wed, 22 Jun 2022 11:07:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819573#M34742</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-06-22T11:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819574#M34743</link>
      <description>&lt;P&gt;Anytime.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Suppose charvar1 contains the values 'a', 'b' and 'c. Your code creates the macro variable a,b,c. However, SAS interprets a as a variable name and 'a' as a character value. You want SAS to interpret as character values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:10:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819574#M34743</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-06-22T11:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819639#M34758</link>
      <description>&lt;P&gt;Your error is one of the reasons you should copy the entire code that generates the error from the LOG along with the error messages. The "code" that you show cannot create that error unless there is much more going on because the code you posted doesn't use the macro variable created in the first step. The code shown would create a variable named CVV1 but you use CV1 in the following code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
select distinct charvar1 into :&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;cvv1&lt;/STRONG&gt;&lt;/FONT&gt; separated by "," from dataset1;
quit;

proc sql; 
create table output1 as 
select *
from dataset2
where charvar1 in (&lt;FONT size="5" color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;cv1&lt;/STRONG&gt;&lt;/FONT&gt;);
quit;&lt;/PRE&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/426087"&gt;@linlin87&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi SAS Community,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I am using the following code to pull make a list and lookup another dataset with this list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
select distinct charvar1 into :cvv1 separated by "," from dataset1;
quit;

proc sql; 
create table output1 as 
select *
from dataset2
where charvar1 in (&amp;amp;cv1);
quit;&lt;/PRE&gt;
&lt;P&gt;but I get the following error:&lt;/P&gt;
&lt;PRE&gt;ERROR: Expression using IN has components that are of different
       data types.
NOTE: The IN referred to may have been transformed from an OR to
      an IN at some point during PROC SQL WHERE clause
      optimization.&lt;/PRE&gt;
&lt;P&gt;I have checked the charvar1 and in both dataset1 and dataset2 it has the format&amp;nbsp;$16. so I don't understand why it is saying that they are different types. Any help would be really great!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 14:34:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819639#M34758</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-22T14:34:42Z</dc:date>
    </item>
    <item>
      <title>Re: Data types error when using "select into" for a character variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819646#M34759</link>
      <description>Yes</description>
      <pubDate>Wed, 22 Jun 2022 14:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Data-types-error-when-using-quot-select-into-quot-for-a/m-p/819646#M34759</guid>
      <dc:creator>linlin87</dc:creator>
      <dc:date>2022-06-22T14:47:17Z</dc:date>
    </item>
  </channel>
</rss>

