<?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: NDC Format Conversion in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401062#M12193</link>
    <description>&lt;P&gt;&lt;img id="robotsurprised" class="emoticon emoticon-robotsurprised" src="https://communities.sas.com/i/smilies/16x16_robot-surprised.png" alt="Robot surprised" title="Robot surprised" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the different segments, Use SCAN() to separate your components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Convert them to numerics using INPUT.&lt;/P&gt;
&lt;P&gt;Use Zw to apply the format and recreate your new variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use CATX() to recreate your new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The required structure is 5-4-2? Note that you never actually say that anywhere. If it's not, you can change the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please post sample data as text, preferable in a data step but at least text. Otherwise it's hard to work with your data and it takes longer for you to get an answer.&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="delete_ndc.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15618i97C92992C3D41780/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_ndc.JPG" alt="delete_ndc.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2017 17:08:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-04T17:08:20Z</dc:date>
    <item>
      <title>NDC Format Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401048#M12192</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hello SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a question on how to get this right. I have a 10 digit NDC code in 3 formats as shown below. I need to add a '0' in specified places based on the format. Below is my code to solve this but I keep getting errors with the use of substring. I do know I can use scan to complete the process. But, I want to know if there is an efficient way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NDC packagecode is same as NDC code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;seq1endpos = find ( ndcpackagecode , "-") ;
seg1 = substr ( ndcpackagecode , 1 , seq1endpos - 1 ) ;
seq2endpos = find ( substr ( ndcpackagecode , seq1endpos + 1 , 10 ) , "-") ;
seg2 = substr ( ndcpackagecode , seq1endpos + 1 , seq2endpos - 1 ) ;
seg3 = substr ( ndcpackagecode , seq1endpos + seq2endpos + 1 , 2 ) ;
compressedcode = compress ( ndcpackagecode , "-" , "") ;
if length(trim(seg1)) = 5 then do ; 
if length(trim(seg2)) = 4 and length(trim(seg3)) = 2 then do ;
ndccode = trim(seg1) || trim(seg2) || trim(seg3) ; ndcmod = 0 ; 
end ; 
if length(trim(seg2)) = 4 and length(trim(seg3)) = 1 then do ;
ndccode = trim(seg1) || trim(seg2) || '0' || trim(seg3) ; ndcmod = 1 ; 
end ; 
if length(trim(seg2)) = 3 and length(trim(seg3)) = 2 then do ;
ndccode = trim(seg1) || '0' || trim(seg2) || trim(seg3) ; ndcmod = 1 ; 
end ; 
if length(trim(seg2)) = 3 and length(trim(seg3)) = 1 then do ;
ndccode = trim(seg1) || '0' || trim(seg2) || '0' || trim(seg3) ; ndcmod = 1 ; 
end ;
end ;
if length(trim(seg1)) = 4 then do ; 
if length(trim(seg2)) = 4 and length(trim(seg3)) = 2 then do ;
ndccode = '0' || trim(seg1) || trim(seg2) || trim(seg3) ; ndcmod = 1 ; 
end ; 
if length(trim(seg2)) = 4 and length(trim(seg3)) = 1 then do ;
ndccode = '0' || trim(seg1) || trim(seg2) || '0' || trim(seg3) ; ndcmod = 1 ; 
end ;
end ;

if length(ndccode) ne 11 then ndcbadlength = 1 ; else ndcbadlength = 0 ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;NDC Conversion: 10-digit to 11-digit&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;If 10-digit NDC format is:&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Then add a zero (0) in:&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;&lt;STRONG&gt;Report NDC as:&lt;/STRONG&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;4-4-2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;9999-9999-99&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;1st position &lt;STRONG&gt;0&lt;/STRONG&gt;9999-9999-99&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;09999999999&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;5-3-2&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;99999-999-99&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;6th position 99999-&lt;STRONG&gt;0&lt;/STRONG&gt;999-99&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;99999099999&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;5-4-1&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;99999-9999-9&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;10th position 99999-9999-&lt;STRONG&gt;0&lt;/STRONG&gt;9&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;99999999909&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is another example of how the end result should be:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15617iE79405E9B59CB30D/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Can some one help.&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 16:50:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401048#M12192</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2017-10-04T16:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: NDC Format Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401062#M12193</link>
      <description>&lt;P&gt;&lt;img id="robotsurprised" class="emoticon emoticon-robotsurprised" src="https://communities.sas.com/i/smilies/16x16_robot-surprised.png" alt="Robot surprised" title="Robot surprised" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To calculate the different segments, Use SCAN() to separate your components.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Convert them to numerics using INPUT.&lt;/P&gt;
&lt;P&gt;Use Zw to apply the format and recreate your new variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use CATX() to recreate your new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The required structure is 5-4-2? Note that you never actually say that anywhere. If it's not, you can change the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, please post sample data as text, preferable in a data step but at least text. Otherwise it's hard to work with your data and it takes longer for you to get an answer.&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="delete_ndc.JPG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/15618i97C92992C3D41780/image-size/large?v=v2&amp;amp;px=999" role="button" title="delete_ndc.JPG" alt="delete_ndc.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 17:08:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401062#M12193</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-04T17:08:20Z</dc:date>
    </item>
    <item>
      <title>Re: NDC Format Conversion</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401087#M12195</link>
      <description>&lt;P&gt;Hi Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your solution.&lt;/P&gt;&lt;P&gt;Sorry about the text issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data posted was in 2 forms one as a table and another as a image. I posted the Image due to the formatting issue when as a text.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the help. your solution worked.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2017 17:47:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/NDC-Format-Conversion/m-p/401087#M12195</guid>
      <dc:creator>shasank</dc:creator>
      <dc:date>2017-10-04T17:47:52Z</dc:date>
    </item>
  </channel>
</rss>

