<?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: finding a field in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788603#M40090</link>
    <description>&lt;P&gt;If you can please share/attach an actual Json.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is confidential then you could use a text editor and change the values - but don't touch the Json structure.&lt;/P&gt;</description>
    <pubDate>Thu, 06 Jan 2022 05:10:46 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2022-01-06T05:10:46Z</dc:date>
    <item>
      <title>finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788442#M40078</link>
      <description>Hi All,&lt;BR /&gt;I wish you a happy new year to everyone.&lt;BR /&gt;I have a temporary dataset which has columns like this.&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;&lt;BR /&gt;Here for a particular OrderID it may have multiple ProductID's corresponding to OrderID. But my data is like&lt;BR /&gt;Example: For a OrderID : 12345 it has two ProductID's : abc789, der098I.&lt;BR /&gt;I would like to have a final dataset should be like&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;123451 abc789&lt;BR /&gt;&lt;BR /&gt;123451 der098I</description>
      <pubDate>Wed, 05 Jan 2022 12:28:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788442#M40078</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-05T12:28:11Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788444#M40079</link>
      <description>Continuous&lt;BR /&gt;But I've got the dataset like&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345I abc789&lt;BR /&gt;40028 der098I&lt;BR /&gt;As you have seen above for a OrderID 12345I it has two ProductID's so the OrderID should be same for above mentioned ProductID's but instead of that the OrderID is taking another OrderID instead of repeating the same. So, how can I achieve this feat.&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345I abc789&lt;BR /&gt;12345I der098I&lt;BR /&gt;Please help in achieving this. Any help would be greatly appreciated. Thanks.</description>
      <pubDate>Wed, 05 Jan 2022 12:32:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788444#M40079</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-05T12:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788448#M40080</link>
      <description>&lt;P&gt;Providing a "have" dataset that covers the different cases and showing us the desired result often helps a lot in reducing ambiguity and you will also get quicker the answer you need.&lt;/P&gt;
&lt;P&gt;I had to make a few assumptions so not sure if what I've done will match your reality.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  OrderID='12345'; 
  ProductID='abc789, der098I';
  output;
  OrderID='999'; 
  ProductID='xyz';
  output;
run;

data want;
  set have(rename=(ProductID=_ProductID));
  length ProductID $10;
  _n_terms=countw(_ProductID,',');
  do _i=1 to _n_terms;
    ProductID=strip(scan(_ProductID,_i,','));
    output;
  end;
  drop _:;
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-1641386449604.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67136iD28AA3AA38638B42/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1641386449604.png" alt="Patrick_0-1641386449604.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 12:40:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788448#M40080</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-05T12:40:56Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788452#M40081</link>
      <description>Sorry for the inconveniences caused.&lt;BR /&gt;Initially I've a dataset named have which has:&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;44409 der098I&lt;BR /&gt;Xyz&lt;BR /&gt;&lt;BR /&gt;The dataset I want is:&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;12345 der098I&lt;BR /&gt;44409 xyz&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 12:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788452#M40081</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-05T12:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788455#M40082</link>
      <description>&lt;P&gt;And just by looking at "have" what bit of information tells us that product&amp;nbsp;&lt;SPAN&gt;der098I belongs to order&amp;nbsp;12345?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;And that xyz is the product and not the order id but that we need to use order id&amp;nbsp;44409 here? Please explain the logic required based on the sample data provided.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If I got that right then "have" is an intermediary table that you created earlier in your process? Would it be possible to avoid "shuffling" your data earlier in the process?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 13:06:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788455#M40082</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-05T13:06:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788458#M40083</link>
      <description>Actually I've got this data from an Api&lt;BR /&gt;Where a OrderID is the unique key and for a particular OrderID it has multiple ProductID's.&lt;BR /&gt;I've that data in a temporary table which is like this :&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;44409 der098I&lt;BR /&gt;Empty xyz&lt;BR /&gt;This is the table I have here 12345 has two ProductID's abc789, der098I and for 44409 it has one ProductID xyz.&lt;BR /&gt;The final table supposed to look like :&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;12345 der098I&lt;BR /&gt;44409 xyz.&lt;BR /&gt;I hope I cleared everything.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Jan 2022 13:15:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788458#M40083</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-05T13:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788477#M40084</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;&lt;EM&gt;This is the table I have here 12345 has two ProductID's abc789, der098I and for 44409 it has one&lt;/EM&gt;"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;That's what you know somehow but how can someone else tell just by "looking" at the have data you shared. Can you explain the required logic? It's not obvious to me.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you retrieve the data via an API call then how do you read this data into a SAS table? Eventually that's the place where something needs to change.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 15:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788477#M40084</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-05T15:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788492#M40086</link>
      <description>&lt;P&gt;Looks like rather than "finding a field" it seems like you're trying to fill in missing values with previous values.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that's correct, here's something that will fill it in, in a new variable. If this works it's easy enough to rename and drop the old variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*create example data;
data have;
  OrderID='12345'; 
  ProductID='abc789';
  output;
  OrderID='44409';
  ProductID= 'der098I';
  output;
  OrderID=''; 
  ProductID='xyz';
  output;
run;


*answer to question - replace HAVE with your original data set name;
data want;
set have;

*keeps the ID in cases where it's missing;
retain NewOrderID;

*if not missing then can assign it the OrderID;
if not missing(OrderID) then NewOrderID = OrderID;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Actually I've got this data from an Api&lt;BR /&gt;Where a OrderID is the unique key and for a particular OrderID it has multiple ProductID's.&lt;BR /&gt;I've that data in a temporary table which is like this :&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;44409 der098I&lt;BR /&gt;Empty xyz&lt;BR /&gt;This is the table I have here 12345 has two ProductID's abc789, der098I and for 44409 it has one ProductID xyz.&lt;BR /&gt;The final table supposed to look like :&lt;BR /&gt;OrderID ProductID&lt;BR /&gt;12345 abc789&lt;BR /&gt;12345 der098I&lt;BR /&gt;44409 xyz.&lt;BR /&gt;I hope I cleared everything.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jan 2022 16:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788492#M40086</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-05T16:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788586#M40087</link>
      <description>I'm not at all trying to fill the missing's. Please go through previous posts as well so that you can able to understand</description>
      <pubDate>Thu, 06 Jan 2022 03:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788586#M40087</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-06T03:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788587#M40088</link>
      <description>The Api has json data so when I fetch that data it has these two fields named OrderID and ProductID but there's no pair for OrderID and ProductID that's the reason why it is taking another OrderID instead of repeating the same for associated ProductID's.</description>
      <pubDate>Thu, 06 Jan 2022 03:37:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788587#M40088</guid>
      <dc:creator>Pandu2</dc:creator>
      <dc:date>2022-01-06T03:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788591#M40089</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/405593"&gt;@Pandu2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I'm not at all trying to fill the missing's. Please go through previous posts as well so that you can able to understand&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I did read them. I don't seem to be the only one not understanding you but I'll leave it to others now.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 03:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788591#M40089</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-01-06T03:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788603#M40090</link>
      <description>&lt;P&gt;If you can please share/attach an actual Json.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the data is confidential then you could use a text editor and change the values - but don't touch the Json structure.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 05:10:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788603#M40090</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2022-01-06T05:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: finding a field</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788606#M40091</link>
      <description>&lt;P&gt;If you are dealing with hierarchical data, like JSON, use a JSON map to map the structure to what SAS needs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See Chris' post here for ideas:&amp;nbsp;&lt;A href="https://blogs.sas.com/content/sasdummy/2016/12/02/json-libname-engine-sas/" target="_blank"&gt;Reading data with the SAS JSON libname engine - The SAS Dummy&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather than trying to wrangle SAS's XY layout (row/column), map the JSON tree structure so it creates the SAS layout for you.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 05:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/finding-a-field/m-p/788606#M40091</guid>
      <dc:creator>AlanC</dc:creator>
      <dc:date>2022-01-06T05:46:56Z</dc:date>
    </item>
  </channel>
</rss>

