<?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: create xyz table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478593#M123426</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge one two;
   by x;
   output;
   call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 17 Jul 2018 09:53:14 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2018-07-17T09:53:14Z</dc:date>
    <item>
      <title>create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478567#M123418</link>
      <description>&lt;P&gt;Hi could&amp;nbsp;you please help on this&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data one;&lt;BR /&gt;input x y;&lt;BR /&gt;datalines ;&lt;BR /&gt;1 2&lt;BR /&gt;1 3&lt;/P&gt;&lt;P&gt;2 4&lt;/P&gt;&lt;P&gt;2 5&lt;/P&gt;&lt;P&gt;2 9&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data two;&lt;BR /&gt;input x z;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;cards;&lt;BR /&gt;1 4&lt;BR /&gt;1 5&lt;BR /&gt;1 6&lt;/P&gt;&lt;P&gt;2 3&lt;/P&gt;&lt;P&gt;2 7&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;need output like this&lt;/P&gt;&lt;P&gt;x y z&lt;/P&gt;&lt;P&gt;1 2 4&lt;/P&gt;&lt;P&gt;1 3 5&lt;/P&gt;&lt;P&gt;1 .&amp;nbsp; 6&lt;/P&gt;&lt;P&gt;2 4 3&lt;/P&gt;&lt;P&gt;2 5 7&lt;/P&gt;&lt;P&gt;2 9 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 06:38:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478567#M123418</guid>
      <dc:creator>kyath_sas</dc:creator>
      <dc:date>2018-07-17T06:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478568#M123419</link>
      <description>&lt;P&gt;Do like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   call missing(y,z);
   merge one two;
   by x;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 07:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478568#M123419</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T07:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478576#M123421</link>
      <description>&lt;P&gt;I have a huge data&amp;nbsp;&lt;/P&gt;&lt;P&gt;varible values are 'ab-05-abc-$200'&lt;/P&gt;&lt;P&gt;&amp;nbsp;i am getting below error could you suggest on this&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Variable&amp;nbsp;y has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable&amp;nbsp;z has been defined as both character and numeric.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 08:07:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478576#M123421</guid>
      <dc:creator>kyath_sas</dc:creator>
      <dc:date>2018-07-17T08:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478577#M123422</link>
      <description>&lt;P&gt;The error message means exactly what it says: That the variable y is defined as character in one place and as numeric in another.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you only have two data sources as in your example? If so run a PROC CONTENTS on both data sets to find the error&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 08:09:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478577#M123422</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T08:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478580#M123423</link>
      <description>all are char only</description>
      <pubDate>Tue, 17 Jul 2018 08:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478580#M123423</guid>
      <dc:creator>kyath_sas</dc:creator>
      <dc:date>2018-07-17T08:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478583#M123424</link>
      <description>&lt;P&gt;The SAS log does not lie to you. Somewhere you have a version of the variable y that is numeric.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just to be clear: You want the variables to be character, correct? Because in the example data you post, all variables including y and z are numeric?&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 08:39:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478583#M123424</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T08:39:03Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478587#M123425</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/218287"&gt;@kyath_sas&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;all are char only&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can't be. In the example data in your initial post, ALL variables are &lt;U&gt;numeric&lt;/U&gt;. If you are unsure how to get correct data steps from your &lt;EM&gt;real&lt;/EM&gt; data, use the macro from my footnote to convert a part of your real datasets to data steps.&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 08:53:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478587#M123425</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-07-17T08:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478593#M123426</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   merge one two;
   by x;
   output;
   call missing(of _all_);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 17 Jul 2018 09:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478593#M123426</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-07-17T09:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478631#M123441</link>
      <description>&lt;P&gt;Ksharp, can you please explain how&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;output&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
   call &lt;SPAN class="token function"&gt;missing&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;of &lt;SPAN class="token keyword"&gt;_all_&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gets rid of&lt;/P&gt;&lt;P&gt;ERROR: Variable&amp;nbsp;y has been defined as both character and numeric.&lt;BR /&gt;ERROR: Variable&amp;nbsp;z has been defined as both character and numeric.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is variable y and z character or numeric in data=want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Margaret&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478631#M123441</guid>
      <dc:creator>janus58</dc:creator>
      <dc:date>2018-07-17T13:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478633#M123442</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71096"&gt;@janus58&lt;/a&gt;&amp;nbsp;it does not.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It simply ensures that the variable values are missing when no table contributes to the merge. if you remove the CALL MISSING part, no missing values will appear. Instead the variables are retained&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 13:10:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478633#M123442</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-07-17T13:10:08Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478854#M123518</link>
      <description>&lt;P&gt;If your two files are already sorted by x I would use the following method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
  input x $ y $;
  datalines ;
1 2
1 3
2 4
2 5
2 9
;

data two;
  input x $ z $; 
  cards;
1 4
1 5
1 6
2 3
2 7
;

data one_a;
  set one;
  by x;
  if first.x then seq=1;
  else seq+1;
run;

data two_a;
  set two;
  by x;
  if first.x then seq=1;
  else seq+1;
run;

data want (drop=seq);
  merge one_a two_a;
  by x seq;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71096"&gt;@janus58&lt;/a&gt;: the placement of the call missing statement is critical. If it is the first assignment of those variables, it will make the fields numeric. That is why&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;'s code wouldn't produce a mixed case error, as the call missing will assign them as character (as they've already been assigned that way).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, in the present case, it isn't needed. Since it is a many to many merge, that is the problem that has to be overcome. I did that by assigning seq numbers and including that variable in the by statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 22:09:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478854#M123518</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2018-07-17T22:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: create xyz table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478886#M123534</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the way it's supposed to be done. Moreover, the files with the surrogate key created in this manner can be used in a full SQL join by those who prefer it to MERGE. Note, however, that using views rather than physical data sets is better in terms of performance and space utilization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first time I saw this method proposed was 20 years ago, by Ian Whitlock on SAS-L. At the time, he noted that negating the normal behavior of a many-to-many MERGE statement by forcing non-key variables to missing values is bad programming practice. MISSING (of _ALL_) is an even more deadly sin since it's easy to perceive what kind of havoc it can wreak on unsuspecting variables other than those targeted for nullification.&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jul 2018 02:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/create-xyz-table/m-p/478886#M123534</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2018-07-18T02:06:22Z</dc:date>
    </item>
  </channel>
</rss>

