<?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 Replace blanks in column using lookup table - don't want to use leftjoin in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844452#M333842</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basic version of my data is shown in the table below, the blank Location is due to prior uploads into this dataset not including the Location field.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;Period&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;006_Product&lt;/TD&gt;&lt;TD&gt;35345&lt;/TD&gt;&lt;TD&gt;202207&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;007_Product&lt;/TD&gt;&lt;TD&gt;25346&lt;/TD&gt;&lt;TD&gt;202208&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;008_Product&lt;/TD&gt;&lt;TD&gt;3255&lt;/TD&gt;&lt;TD&gt;202209&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;67777&lt;/TD&gt;&lt;TD&gt;202210&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;251581&lt;/TD&gt;&lt;TD&gt;202210&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have this mapping table available:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;006_Product&lt;/TD&gt;&lt;TD&gt;GLP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;007_Product&lt;/TD&gt;&lt;TD&gt;AHT2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;008_Product&lt;/TD&gt;&lt;TD&gt;GLP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;010_Product&lt;/TD&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if there is a way of doing something like if Location = "" then use the mapping table to lookup the product code in Class and set the Location to the correct value based on the mapping table. I know I could do a join but from previous experiences using this function it would append a new Location column the dataset; I want to keep the columns in the same order and also not overwrite the Locations that are already in the current dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2022 18:48:18 GMT</pubDate>
    <dc:creator>mattbnorris</dc:creator>
    <dc:date>2022-11-15T18:48:18Z</dc:date>
    <item>
      <title>Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844452#M333842</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basic version of my data is shown in the table below, the blank Location is due to prior uploads into this dataset not including the Location field.&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;Period&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;006_Product&lt;/TD&gt;&lt;TD&gt;35345&lt;/TD&gt;&lt;TD&gt;202207&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;007_Product&lt;/TD&gt;&lt;TD&gt;25346&lt;/TD&gt;&lt;TD&gt;202208&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;008_Product&lt;/TD&gt;&lt;TD&gt;3255&lt;/TD&gt;&lt;TD&gt;202209&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;67777&lt;/TD&gt;&lt;TD&gt;202210&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;251581&lt;/TD&gt;&lt;TD&gt;202210&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also have this mapping table available:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Location&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;006_Product&lt;/TD&gt;&lt;TD&gt;GLP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;007_Product&lt;/TD&gt;&lt;TD&gt;AHT2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;008_Product&lt;/TD&gt;&lt;TD&gt;GLP&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;009_Product&lt;/TD&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;010_Product&lt;/TD&gt;&lt;TD&gt;AHT&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know if there is a way of doing something like if Location = "" then use the mapping table to lookup the product code in Class and set the Location to the correct value based on the mapping table. I know I could do a join but from previous experiences using this function it would append a new Location column the dataset; I want to keep the columns in the same order and also not overwrite the Locations that are already in the current dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Matt&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 18:48:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844452#M333842</guid>
      <dc:creator>mattbnorris</dc:creator>
      <dc:date>2022-11-15T18:48:18Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844495#M333860</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Location $ Class $ Value Period;
infile datalines dlm = '|';
datalines;
   |006_Product|35345|202207  
   |007_Product|25346|202208  
   |008_Product|3255 |202209  
AHT|009_Product|67777|202210  
AHT|009_Product|251581|202210 
;

data map;
input Class :$11. Location $;
datalines;
006_Product GLP  
007_Product AHT2 
008_Product GLP  
009_Product AHT  
010_Product AHT  
;

data want;

   if _N_ = 1 then do;
      dcl hash h(dataset : 'map');
      h.definekey('Class');
      h.definedata('Location');
      h.definedone();
   end;

   set have;

   if Location = '' then h.find();
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;Result:&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Location  Class     Value   Period
GLP       006_Prod  35345   202207
AHT2      007_Prod  25346   202208
GLP       008_Prod  3255    202209
AHT       009_Prod  67777   202210
AHT       009_Prod  251581  202210&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 21:05:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844495#M333860</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-15T21:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844497#M333861</link>
      <description>&lt;P&gt;It doesn't have to add a new column. You can use coalesce to only replace values that are not missing.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select coalesce(t1.location, t2.location) as location, t1.class, t1.value, t1.period
from have as t1
left join t2
on t1.class=t2.class
order by t1.period;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;You could also create a format from table2 and apply it via a data step.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lookup_fmt;
set table2;
fmtname = 'location_fmt';
type = 'C';
start = class;
label = location;
run;

proc format cntlin=lookup_fmt;
run;

data want;
set have;
if missing(location) then location = put(class, $location_fmt.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/422940"&gt;@mattbnorris&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basic version of my data is shown in the table below, the blank Location is due to prior uploads into this dataset not including the Location field.&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Location&lt;/TD&gt;
&lt;TD&gt;Class&lt;/TD&gt;
&lt;TD&gt;Value&lt;/TD&gt;
&lt;TD&gt;Period&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;006_Product&lt;/TD&gt;
&lt;TD&gt;35345&lt;/TD&gt;
&lt;TD&gt;202207&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;007_Product&lt;/TD&gt;
&lt;TD&gt;25346&lt;/TD&gt;
&lt;TD&gt;202208&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;008_Product&lt;/TD&gt;
&lt;TD&gt;3255&lt;/TD&gt;
&lt;TD&gt;202209&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AHT&lt;/TD&gt;
&lt;TD&gt;009_Product&lt;/TD&gt;
&lt;TD&gt;67777&lt;/TD&gt;
&lt;TD&gt;202210&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;AHT&lt;/TD&gt;
&lt;TD&gt;009_Product&lt;/TD&gt;
&lt;TD&gt;251581&lt;/TD&gt;
&lt;TD&gt;202210&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also have this mapping table available:&lt;/P&gt;
&lt;TABLE border="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;Class&lt;/TD&gt;
&lt;TD&gt;Location&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;006_Product&lt;/TD&gt;
&lt;TD&gt;GLP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;007_Product&lt;/TD&gt;
&lt;TD&gt;AHT2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;008_Product&lt;/TD&gt;
&lt;TD&gt;GLP&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;009_Product&lt;/TD&gt;
&lt;TD&gt;AHT&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;010_Product&lt;/TD&gt;
&lt;TD&gt;AHT&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to know if there is a way of doing something like if Location = "" then use the mapping table to lookup the product code in Class and set the Location to the correct value based on the mapping table. I know I could do a join but from previous experiences using this function it would append a new Location column the dataset; I want to keep the columns in the same order and also not overwrite the Locations that are already in the current dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help is appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Matt&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 21:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844497#M333861</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-15T21:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844554#M333892</link>
      <description>&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Thanks for the interesting example of lookup.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="jCAhz ChMk0b"&gt;&lt;SPAN class="ryNqvb"&gt;Find succeeds even if the "Class variable" of "have dataset" is truncated at 8 characters.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 05:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844554#M333892</guid>
      <dc:creator>kimiko</dc:creator>
      <dc:date>2022-11-16T05:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844575#M333904</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/222861"&gt;@kimiko&lt;/a&gt;&amp;nbsp;sure thing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just edited my code with sufficient lengths for Class in both data sets. It succeeds by 'luck' only because the hash object inherits variable lengths from the pdv (parameter type matching).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 07:58:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844575#M333904</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-16T07:58:59Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844581#M333905</link>
      <description>hey, perter,&lt;BR /&gt;why you guys always use "Have" or "Want" as the data set name? Is there any implications for those names?</description>
      <pubDate>Wed, 16 Nov 2022 09:06:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844581#M333905</guid>
      <dc:creator>HumbleMe</dc:creator>
      <dc:date>2022-11-16T09:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844582#M333906</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/430851"&gt;@HumbleMe&lt;/a&gt;&amp;nbsp;welcome to the SAS Communities.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good question. But no. None other than that the 'Have' data set represents the data that we Have and the 'Want' data set represents the data set / result that we want &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 09:08:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844582#M333906</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-11-16T09:08:28Z</dc:date>
    </item>
    <item>
      <title>Re: Replace blanks in column using lookup table - don't want to use leftjoin</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844583#M333907</link>
      <description>Alright, that's what the words exactly stand for &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt; thanks Peter.</description>
      <pubDate>Wed, 16 Nov 2022 09:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Replace-blanks-in-column-using-lookup-table-don-t-want-to-use/m-p/844583#M333907</guid>
      <dc:creator>HumbleMe</dc:creator>
      <dc:date>2022-11-16T09:22:44Z</dc:date>
    </item>
  </channel>
</rss>

