<?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 SAS Character Variable comparision in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44364#M9078</link>
    <description>I have two datasets.I have to create an output dataset from these two with the condition that var2 of dataset1 should match the var2 of dataset2. Only concern is Var2 is $9 here and $32 in the second dataset.&lt;BR /&gt;
&lt;BR /&gt;
Example:&lt;BR /&gt;
&lt;BR /&gt;
var1     var2($9)&lt;BR /&gt;
-----------------------&lt;BR /&gt;
1      0000283&lt;BR /&gt;
2      731823&lt;BR /&gt;
3      1073388&lt;BR /&gt;
4      12&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
varX     var2($32)&lt;BR /&gt;
-----------------------&lt;BR /&gt;
1      000002837&lt;BR /&gt;
2      000731828&lt;BR /&gt;
3      001073388&lt;BR /&gt;
4      000161499&lt;BR /&gt;
&lt;BR /&gt;
How to get the result as :&lt;BR /&gt;
&lt;BR /&gt;
var1 varx &lt;BR /&gt;
==========&lt;BR /&gt;
3    3    &lt;BR /&gt;
&lt;BR /&gt;
I tried left, trim, input and put fuctions but i am getting absurd results. Thats becaue when I convert the character to numeric for comparasion purpose, the values wiht more than 8 characters are trimmed and so wrong matching ouptut is generate. Is there any way I can compare this two variable.&lt;BR /&gt;
&lt;BR /&gt;
Note : Size of both vairbles are $9 and $32 and the values in this are starting from 1 character to any.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help...</description>
    <pubDate>Thu, 21 Jan 2010 16:38:09 GMT</pubDate>
    <dc:creator>Sarojkumar</dc:creator>
    <dc:date>2010-01-21T16:38:09Z</dc:date>
    <item>
      <title>SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44364#M9078</link>
      <description>I have two datasets.I have to create an output dataset from these two with the condition that var2 of dataset1 should match the var2 of dataset2. Only concern is Var2 is $9 here and $32 in the second dataset.&lt;BR /&gt;
&lt;BR /&gt;
Example:&lt;BR /&gt;
&lt;BR /&gt;
var1     var2($9)&lt;BR /&gt;
-----------------------&lt;BR /&gt;
1      0000283&lt;BR /&gt;
2      731823&lt;BR /&gt;
3      1073388&lt;BR /&gt;
4      12&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
varX     var2($32)&lt;BR /&gt;
-----------------------&lt;BR /&gt;
1      000002837&lt;BR /&gt;
2      000731828&lt;BR /&gt;
3      001073388&lt;BR /&gt;
4      000161499&lt;BR /&gt;
&lt;BR /&gt;
How to get the result as :&lt;BR /&gt;
&lt;BR /&gt;
var1 varx &lt;BR /&gt;
==========&lt;BR /&gt;
3    3    &lt;BR /&gt;
&lt;BR /&gt;
I tried left, trim, input and put fuctions but i am getting absurd results. Thats becaue when I convert the character to numeric for comparasion purpose, the values wiht more than 8 characters are trimmed and so wrong matching ouptut is generate. Is there any way I can compare this two variable.&lt;BR /&gt;
&lt;BR /&gt;
Note : Size of both vairbles are $9 and $32 and the values in this are starting from 1 character to any.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help...</description>
      <pubDate>Thu, 21 Jan 2010 16:38:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44364#M9078</guid>
      <dc:creator>Sarojkumar</dc:creator>
      <dc:date>2010-01-21T16:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44365#M9079</link>
      <description>Sorry, I initially misunderstood the problem.&lt;BR /&gt;
&lt;BR /&gt;
Here's my modified post.&lt;BR /&gt;
&lt;BR /&gt;
Create a view over the each dataset and convert the variable (alpha) to an numeric equivalent.&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
create view X1 as&lt;BR /&gt;
select var1, input(var2,best.) as VAR2 from INDATA1;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
create view X2 as&lt;BR /&gt;
select varX, input(var2,best.) as VAR2 from INDATA2;&lt;BR /&gt;
quit;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
then merge the views into a single dataset.&lt;BR /&gt;
&lt;BR /&gt;
Should work.&lt;BR /&gt;
&lt;BR /&gt;
Cheers from Portugal&lt;BR /&gt;
&lt;BR /&gt;
Daniel Santos @ &lt;A href="http://www.cgd.pt" target="_blank"&gt;www.cgd.pt&lt;/A&gt;</description>
      <pubDate>Thu, 21 Jan 2010 16:45:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44365#M9079</guid>
      <dc:creator>DanielSantos</dc:creator>
      <dc:date>2010-01-21T16:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44366#M9080</link>
      <description>Thanks Daniel..This works...Can you please tell me how to convert a character variable to numeric vairable if the character variable is more that 8 characters...&lt;BR /&gt;
&lt;BR /&gt;
Ex.  '123456789' or '1234567890' etc</description>
      <pubDate>Thu, 21 Jan 2010 16:54:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44366#M9080</guid>
      <dc:creator>Sarojkumar</dc:creator>
      <dc:date>2010-01-21T16:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44367#M9081</link>
      <description>if only problem is leading 0 then you may use substr and not having to mess up with type switch from char to num.</description>
      <pubDate>Thu, 21 Jan 2010 17:17:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44367#M9081</guid>
      <dc:creator>abdullala</dc:creator>
      <dc:date>2010-01-21T17:17:08Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44368#M9082</link>
      <description>Conversion can be done with the DATA step assignment statement, using the INPUT function and the appropriate INFORMAT/length - example below:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
17   data _null_;&lt;BR /&gt;
18   x = input('123456789012345',15.);&lt;BR /&gt;
19   put x= comma20. / x= best.;&lt;BR /&gt;
20   run;&lt;BR /&gt;
&lt;BR /&gt;
x=123,456,789,012,345&lt;BR /&gt;
x=1.2345679E14&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.00 seconds&lt;BR /&gt;
      cpu time            0.00 seconds&lt;BR /&gt;
&lt;BR /&gt;
To append leading zeros, use the Znn.  SAS format, and if you must convert to a character type variable, use the SAS PUT function with Znn. format in an assignment statement.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 21 Jan 2010 18:28:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44368#M9082</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2010-01-21T18:28:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Character Variable comparision</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44369#M9083</link>
      <description>Thank you all, it worked...</description>
      <pubDate>Fri, 22 Jan 2010 11:05:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Character-Variable-comparision/m-p/44369#M9083</guid>
      <dc:creator>Sarojkumar</dc:creator>
      <dc:date>2010-01-22T11:05:00Z</dc:date>
    </item>
  </channel>
</rss>

