<?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: Combining Observations in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653992#M78844</link>
    <description>&lt;P&gt;You need to standardize the columns you're using to merge the data. SAS got products for this (DataFlux/Data Quality Server) but for your case it's likely good enough if you just analyse the result after your first go (as you already did) and then implement standardization as below. Then use the standardized column for merging.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $country_stdz(upcase)
    'BAHAMAS'       = 'Bahamas'     
    'BAHAMAS (THE)' = 'Bahamas'
    'BAHAMAS, THE'  = 'Bahamas'
  ;
run;

data demo;
  infile datalines truncover;
  input country $20.;
  length country_stdz $20.;
  country_stdz=input(country, $country_stdz.);
  datalines;
Bahamas      
Bahamas (the)
Bahamas, The 
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're reading your data from an external file then you can use the informat also directly in the input statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $country_stdz(upcase)
    'BAHAMAS'       = 'Bahamas'     
    'BAHAMAS (THE)' = 'Bahamas'
    'BAHAMAS, THE'  = 'Bahamas'
  ;
run;

data demo;
  infile datalines truncover;
  input country $country_stdz20.;
  datalines;
Bahamas      
Bahamas (the)
Bahamas, The 
Other country
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1591579642172.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40640i9A80BEB5C3C31AA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1591579642172.png" alt="Patrick_0-1591579642172.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 01:30:54 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2020-06-08T01:30:54Z</dc:date>
    <item>
      <title>Combining Observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653989#M78842</link>
      <description>&lt;P&gt;I am required to merge 5 data sets into one. Not all data sets had the same variables so I have linked the datasets as best as I can. I am now having issues with a couple of the observations, for example:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Bahamas&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bahamas (the)&lt;/TD&gt;&lt;TD&gt;BS&lt;/TD&gt;&lt;TD&gt;BHS&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;367168&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Bahamas, The&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;BHS&lt;/TD&gt;&lt;TD&gt;29930&lt;/TD&gt;&lt;TD&gt;High Income&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is clearly all data relating to the same country, however it is not in one row.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make the data look like this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Bahamas&lt;/TD&gt;&lt;TD&gt;BS&lt;/TD&gt;&lt;TD&gt;BHS&lt;/TD&gt;&lt;TD&gt;29930&lt;/TD&gt;&lt;TD&gt;High Income&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2.9&lt;/TD&gt;&lt;TD&gt;367168&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jun 2020 04:00:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653989#M78842</guid>
      <dc:creator>breebreebree</dc:creator>
      <dc:date>2020-06-07T04:00:18Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653991#M78843</link>
      <description>&lt;P&gt;If you have different countries, convert the following code into a macro.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data original;
input country$14. val1$ val2$ val3 val4$11. val5$ val6$ val7$ val8$ val9$ val10$;
infile datalines missover dsd dlm="";
lines;
Bahamas                        60 9 
Bahamas (the) BS BHS              2.9 367168
Bahamas, The   BHS 29930 High Income
;
run;

data _NULL_;
set original;
if not missing(val1) then call symputx("val1",val1);
else if not missing(val2) then call symputx("val2",val2);
else if not missing(val3) then call symputx("val3",val3);
else if not missing(val4) then call symputx("val4",val4);
else if not missing(val5) then call symputx("val5",val5);
else if not missing(val6) then call symputx("val6",val6);
else if not missing(val7) then call symputx("val7",val7);
else if not missing(val8) then call symputx("val8",val8);
else if not missing(val9) then call symputx("val9",val9);
else if not missing(val10) then call symputx("val10",val10);
run;

data final;
country = "Bahamas";
val1 = "&amp;amp;val1";
val2 = "&amp;amp;val2";
val3 = "&amp;amp;val3";
val4 = "&amp;amp;val4";
val5 = "&amp;amp;val5";
val6 = "&amp;amp;val6";
val7 = "&amp;amp;val7";
val8 = "&amp;amp;val8";
val9 = "&amp;amp;val9";
val10 = "&amp;amp;val10";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Jun 2020 05:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653991#M78843</guid>
      <dc:creator>VENKATAMAHESH</dc:creator>
      <dc:date>2020-06-07T05:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653992#M78844</link>
      <description>&lt;P&gt;You need to standardize the columns you're using to merge the data. SAS got products for this (DataFlux/Data Quality Server) but for your case it's likely good enough if you just analyse the result after your first go (as you already did) and then implement standardization as below. Then use the standardized column for merging.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $country_stdz(upcase)
    'BAHAMAS'       = 'Bahamas'     
    'BAHAMAS (THE)' = 'Bahamas'
    'BAHAMAS, THE'  = 'Bahamas'
  ;
run;

data demo;
  infile datalines truncover;
  input country $20.;
  length country_stdz $20.;
  country_stdz=input(country, $country_stdz.);
  datalines;
Bahamas      
Bahamas (the)
Bahamas, The 
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're reading your data from an external file then you can use the informat also directly in the input statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
  invalue $country_stdz(upcase)
    'BAHAMAS'       = 'Bahamas'     
    'BAHAMAS (THE)' = 'Bahamas'
    'BAHAMAS, THE'  = 'Bahamas'
  ;
run;

data demo;
  infile datalines truncover;
  input country $country_stdz20.;
  datalines;
Bahamas      
Bahamas (the)
Bahamas, The 
Other country
;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1591579642172.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/40640i9A80BEB5C3C31AA7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1591579642172.png" alt="Patrick_0-1591579642172.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 01:30:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/653992#M78844</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-08T01:30:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Observations</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/654005#M78845</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data original;
input country$14. val1$ val2$ val3 val4$11. val5$ val6$ val7$ val8$ val9$ val10$;
infile datalines missover dsd dlm="";
cards;
Bahamas                        60 9 
Bahamas (the) BS BHS              2.9 367168
Bahamas, The   BHS 29930 High Income
;
run;
data temp;
set original;
id=scan(country,1,,'ka');
run;
data want;
 update temp(obs=0) temp;
 by id;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 07 Jun 2020 11:38:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Combining-Observations/m-p/654005#M78845</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-06-07T11:38:31Z</dc:date>
    </item>
  </channel>
</rss>

