<?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: SAS-EG 6.1 useless for variable type changes? in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/249104#M17648</link>
    <description>&lt;P&gt;Check the Data-&amp;gt;Append Table task to see if it does what you want. &amp;nbsp;Append Table uses SQL OUTER UNION CORR to do its work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Feb 2016 01:28:25 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2016-02-10T01:28:25Z</dc:date>
    <item>
      <title>SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248863#M17618</link>
      <description>&lt;UL&gt;&lt;LI&gt;Whenever I try to match an alpha-numeric&amp;nbsp;variable with a numeric&amp;nbsp;variable from other datasets, there seems to be no work around. There is no easy interface for changing the variable type. The put function always fails when redifining a new variable saying a string format needs a string argument. I simply must revert back to coding to get these things done.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there something I haven't tried?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 14:49:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248863#M17618</guid>
      <dc:creator>JBossIsDown</dc:creator>
      <dc:date>2016-02-09T14:49:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248865#M17619</link>
      <description>&lt;P&gt;When you get this type of message:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;The put function always fails when redifining a new variable saying a string format needs a string argument&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it sounds like you are attempting to apply a format defined for character to a numeric variable. If this is a custom format and you want to format numerics then make a version of the format for use with numbers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may indicate you have a variable you think is character that isn't. You might want to provide more details on what you are attempting.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 15:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248865#M17619</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-09T15:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248867#M17620</link>
      <description>&lt;P&gt;I didn't create the datasets, I am trying to match one database that has numbers in numeric variable types, and another that uses the same numbers in an alpha-numeric type. SAS-EG has functionality to join the tables, but only if the type matches. I want to know if there is something I can do to change variable types, without coding.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 15:06:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248867#M17620</guid>
      <dc:creator>JBossIsDown</dc:creator>
      <dc:date>2016-02-09T15:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248877#M17622</link>
      <description>&lt;P&gt;In short no. Once a variable is created in a dataset it's type is fixed.&lt;/P&gt;
&lt;P&gt;To create a NEW dataset with a variable of the same name but different type (numeric to character);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data new;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set old (rename=(variablename=oldvar));&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; length variablename $ 10; /* replace 10 with the length of the variable you are going to match on in the other dataset*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; variablename = put(oldvar,format.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; drop oldvar;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And use New for the match.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or using SQL to join tables you can use something like this if the variable is being used to match records:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table matched as&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; select dataset1,var1, dataset1.var2, dataset2.othervar1, dataset2.othervar2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; from dataset1 join dataset2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on put(dataset1.variable,format.) = dataset2.variable;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 15:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248877#M17622</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-02-09T15:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248880#M17624</link>
      <description>&lt;P&gt;Yeah, this is exactly what&amp;nbsp;I was doing. I was hoping for some EG functionality for this, oh well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 15:33:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248880#M17624</guid>
      <dc:creator>JBossIsDown</dc:creator>
      <dc:date>2016-02-09T15:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248991#M17630</link>
      <description>&lt;P&gt;This is a&amp;nbsp;&lt;STRONG&gt;super&lt;/STRONG&gt; common scenario. &amp;nbsp;You've got to join two different data sources by some primary key field, and the two sources store the field in different ways. &amp;nbsp;The most common case is an ID field (like a customer ID) that is stored as a number in one table and as a character in another. &amp;nbsp;Or another common case: ZIP code. &amp;nbsp;(We can all agree that ZIP codes should be character, right? After all, some ZIP codes have leading zeros! I'm looking at you, Boston!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very often, one of the data sources is an Excel spreadsheet -- where "data type" is a nebulous concept and a field is imported into SAS using the wrong type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's not always practical to change one of the data sources to match the other, or to create a new column in one table so that it can match the key field you want to join. &amp;nbsp;But &lt;STRONG&gt;there is a way&lt;/STRONG&gt; to accomplish this &lt;EM&gt;without&lt;/EM&gt; modifying either of your source tables: create a third table as a key lookup. &amp;nbsp;You can accomplish this step, plus the subsequent join, in the Query Builder.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's take an example. &amp;nbsp;First, I need to create some data that features the mismatched keys:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data classW;
 length ID 8;
 set sashelp.class(keep=name weight);
 ID=_N_;
run;

data classH;
 length ID $ 3;
 set sashelp.class(keep=sex height);
 ID=put(_N_,z3.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This results in two tables that contain different data details, and a "common" (but differently typed) key of&amp;nbsp;&lt;STRONG&gt;ID&lt;/STRONG&gt;:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1807i046840CA362084B9/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="baddata.png" title="baddata.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CLASSW uses a numeric ID. &amp;nbsp;CLASSH uses a 3-character ID that contains digits, formatted with leading zeros.&amp;nbsp;In my opinion, the better practice is a character-based ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To solve, let's use the Query Builder to create a lookup table. &amp;nbsp;Starting with the CLASSW data set, we'll create a two-column lookup. &amp;nbsp;One column is the numeric ID in CLASSW, and the second column is a character version (called ID_Char), formatted with the leading zeros. &amp;nbsp;I used&amp;nbsp;&lt;STRONG&gt;put(&lt;/STRONG&gt;t1.ID, Z3.) to create a Computed Column for&amp;nbsp;character version. &amp;nbsp;Remember, the&amp;nbsp;&lt;STRONG&gt;put()&lt;/STRONG&gt; function always results in a character value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1808i24C1153E9BF0A1E3/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="computed_char.png" title="computed_char.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The result? A narrow data set with just the two columns:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1809i14E2E288BA805D65/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="lookup.png" title="lookup.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your data contains a lot of unique keys, you might be concerned that this new table can get really large. &amp;nbsp;But I think that you'll find that in most cases, the data set won't actually occupy much storage even if you have millions of records. &amp;nbsp;In my example case, the columns add up to only 8 bytes per record.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now we can create another&amp;nbsp;query in the Query Builder to join all three of these tables: the two source tables plus the lookup table. &amp;nbsp;This 3-way inner join uses the lookup table as the go-between. &amp;nbsp;Notice the INNER JOIN conditions listed in the &lt;STRONG&gt;Join Order&lt;/STRONG&gt; section.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1810i9DC2856C3090F9DC/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="threeway.png" title="threeway.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We'll select the fields we want to keep from each table. &amp;nbsp;We don't need to keep anything from the lookup table:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1811i1815BEE1521BA721/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="qselect.png" title="qselect.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And here's our successful merged result:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1812i3D32C4D8F36DD525/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="result.png" title="result.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does this look like in the process flow? &amp;nbsp;Here's my example. &amp;nbsp;Note that the only "program" code is the bit I used to produce the messy data scenario in the first place.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1813i28CC9BDB20E16A5F/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="pf.png" title="pf.png" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 17:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/248991#M17630</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-02-09T17:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/249019#M17639</link>
      <description>&lt;P&gt;Thanks Chris, this works well. But what if the two tables have different id's? Won't the inner joins miss those?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, lets say I do a full outer join for tables&amp;nbsp;that have&amp;nbsp;columns of the same name. Joined by ID.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPE&lt;/P&gt;&lt;P&gt;001&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Shirt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TYPE&lt;/P&gt;&lt;P&gt;002&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; PANTS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My new set will have three columns. ID&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t1.TYPE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t2.TYPE&lt;/P&gt;&lt;P&gt;I just want the one column Type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;any ideas?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2016 19:03:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/249019#M17639</guid>
      <dc:creator>JBossIsDown</dc:creator>
      <dc:date>2016-02-09T19:03:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS-EG 6.1 useless for variable type changes?</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/249104#M17648</link>
      <description>&lt;P&gt;Check the Data-&amp;gt;Append Table task to see if it does what you want. &amp;nbsp;Append Table uses SQL OUTER UNION CORR to do its work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Feb 2016 01:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/SAS-EG-6-1-useless-for-variable-type-changes/m-p/249104#M17648</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2016-02-10T01:28:25Z</dc:date>
    </item>
  </channel>
</rss>

