<?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: Merging two datasets by variable in different formats in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821547#M324347</link>
    <description>Thank you for replying. These are SAS datasets stored in a SAS server as such. How do I check more details on the said variable?</description>
    <pubDate>Tue, 05 Jul 2022 06:34:02 GMT</pubDate>
    <dc:creator>Novice_</dc:creator>
    <dc:date>2022-07-05T06:34:02Z</dc:date>
    <item>
      <title>Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821525#M324330</link>
      <description>&lt;P&gt;I have two datasets with an id variable to merge them with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data1:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;variable name=id&lt;/P&gt;&lt;P&gt;variable type=character&lt;/P&gt;&lt;P&gt;length 255&lt;/P&gt;&lt;P&gt;format $255.&lt;/P&gt;&lt;P&gt;informat $255.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Data2:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;variable name=patid&lt;/P&gt;&lt;P&gt;variable type= numeric&lt;/P&gt;&lt;P&gt;length 8&lt;/P&gt;&lt;P&gt;format 11.&lt;/P&gt;&lt;P&gt;informat 11.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to use the following code to convert the numeric variable in data 2 to character for merging:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data new;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;set data2;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;id=put(patid, $255.);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;However, it gives me the following error:&lt;/P&gt;&lt;P&gt;ERROR 29-185: Width specified for format is invalid.&lt;/P&gt;&lt;P&gt;I tried a format with shorter length and then tried merging. The complete code is below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data new;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;set data2;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;id=put(patid, $3.);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc sort data=data1;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;by id;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc sort data=new;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;by id;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;Data final;&lt;BR /&gt;merge data1(in=in1) new (in=in2);&lt;BR /&gt;by id;&lt;BR /&gt;if in1;&lt;BR /&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;The above code runs but for the variables within the data new, I am getting missing values in the final table. So the merge was actually not successful. Can anyone please help me what to do? Thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 03:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821525#M324330</guid>
      <dc:creator>Novice_</dc:creator>
      <dc:date>2022-07-05T03:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821531#M324334</link>
      <description>&lt;P&gt;You will need to find out more about your data to make this happen.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While your variable is $255 in the first data set, how many characters are actually needed?&amp;nbsp; Are all the values left-hand-justified?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You will need to produce an exact match between the two data sets, so you need to know what is in your data.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 04:22:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821531#M324334</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-07-05T04:22:13Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821538#M324339</link>
      <description>&lt;P&gt;Both of the variable specifications point to an unstable data import process. How does your data arrive in SAS?&lt;/P&gt;
&lt;P&gt;The fact that the numeric variant has a format of 11. lets me suspect that the id values are 11-digit strings, but you need to verify that with the character variant.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 05:08:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821538#M324339</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-05T05:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821546#M324346</link>
      <description>Thank you for the reply. These are SAS datasets in a SAS server</description>
      <pubDate>Tue, 05 Jul 2022 06:31:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821546#M324346</guid>
      <dc:creator>Novice_</dc:creator>
      <dc:date>2022-07-05T06:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821547#M324347</link>
      <description>Thank you for replying. These are SAS datasets stored in a SAS server as such. How do I check more details on the said variable?</description>
      <pubDate>Tue, 05 Jul 2022 06:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821547#M324347</guid>
      <dc:creator>Novice_</dc:creator>
      <dc:date>2022-07-05T06:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821549#M324349</link>
      <description>&lt;P&gt;Then you must first get to really Know Your Data (Maxim 3). See how the IDs are stored in the character variant. Are they left- or right-aligned? Is there a constant number of digits, or does this change? Are there leading zeroes?&lt;/P&gt;
&lt;P&gt;If you provide sufficient examples, we can help you further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Although you work with SAS datasets, this does not mean the data originated in SAS (nobody uses SAS to run a business database). So I still hold it that the process that gets the data from the original source into SAS is flawed.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 07:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/821549#M324349</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-07-05T07:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823990#M325386</link>
      <description>&lt;P&gt;The variable patid prints as below:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Novice__0-1658182170038.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73446i8F1256A71DF4E0A5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Novice__0-1658182170038.png" alt="Novice__0-1658182170038.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 22:09:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823990#M325386</guid>
      <dc:creator>Novice_</dc:creator>
      <dc:date>2022-07-18T22:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823992#M325387</link>
      <description>&lt;P&gt;Thank you for your reply. It seems it is left aligned. All ids have 3 characters. I so not see any leading zeros but I am not sure if there are blanks after. The variable prints as below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Novice__0-1658182344694.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73447i67E203D8BA9C0724/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Novice__0-1658182344694.png" alt="Novice__0-1658182344694.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 22:12:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823992#M325387</guid>
      <dc:creator>Novice_</dc:creator>
      <dc:date>2022-07-18T22:12:40Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823999#M325390</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/393584"&gt;@Novice_&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your reply. It seems it is left aligned. All ids have 3 characters. I so not see any leading zeros but I am not sure if there are blanks after. The variable prints as below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Novice__0-1658182344694.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73447i67E203D8BA9C0724/image-size/small?v=v2&amp;amp;px=200" role="button" title="Novice__0-1658182344694.png" alt="Novice__0-1658182344694.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You cannot tell if the values are left aligned from looking at that photograph.&amp;nbsp; The ODS output engine "eats" leading spaces.&lt;/P&gt;
&lt;P&gt;Either print the value to plain old text output.&lt;/P&gt;
&lt;P&gt;Or print the values using $QUOTE or $HEX format so you can see if there are leading spaces.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 22:48:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/823999#M325390</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-07-18T22:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/911952#M359562</link>
      <description>&lt;P&gt;Hi Team, I also having the same issue I want merging 5 table by using (in=). And renaming the variable and using the by statement&amp;nbsp; by using the (=) is its works.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 11:45:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/911952#M359562</guid>
      <dc:creator>Bibishan_Rathod</dc:creator>
      <dc:date>2024-01-18T11:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Merging two datasets by variable in different formats</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/911957#M359564</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/407431"&gt;@Bibishan_Rathod&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Team, I also having the same issue I want merging 5 table by using (in=). And renaming the variable and using the by statement&amp;nbsp; by using the (=) is its works.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hello. I'm glad you are trying to help, but this is really way to brief to understand. Its really unclear what problem you are trying solve, and I don't understand the solution you describe. Please spend more time on this and explain in detail, with example data and with actual code.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jan 2024 12:07:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging-two-datasets-by-variable-in-different-formats/m-p/911957#M359564</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-01-18T12:07:20Z</dc:date>
    </item>
  </channel>
</rss>

