<?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 How to create NewIDs based on Macro IDs list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625145#M184239</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data X which contains macro ID list, and I have a Sample dataset Y which contains all different kind of formats.&amp;nbsp;&amp;nbsp; I would like to create a NewID (see data Want) &amp;nbsp;based on the macro ID list from TempID_1 to TempID_4 (see data Y).&amp;nbsp;&amp;nbsp; Is there a way to approach this?&amp;nbsp; Thank you.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
format ID $10. ;
input ID $10. ;
cards;
1156
1789
0001147
0001597
0598
0002489
;
run;
 
data y;
      infile datalines dsd;
  input TempID_1 : $15. TempID_2 : $15.  TempID_3 : $15. TempID_4 : $15.;
datalines;
21156, , , ,
, 000-1147, , ,    
, , Car_1597, ,
, , , ID 1789,
C1156, , , ,
, 1789 Car,  , ,
, , ID__0598-Car, ,
200, 9, X1O23, UP689,
2001156, , , ,
, , ,  1597 UP,
208, 9,  8MO23, UV689,
, 8,  HL 2489, GJ627,
;



data want;
	infile datalines dsd;
  input TempID_1 : $15. TempID_2 : $15.  TempID_3 : $15. TempID_4 : $15. NewID : $15. ;
datalines;
21156, , , , 1156,
, 000-1147, , , 000147,   
, , Car_1597, , 0001597,
, , , ID 1789, 1789,
C1156, , , , 1156,
, 1789 Car,  , , 1789,
, , ID__0598-Car, , 0598,
200, 9, X1O23, UP689, ,
2001156, , , , 1156,
, , ,  1597 UP, 0001579,
208, 9,  8MO23, UV689, ,
, 8,  HL 2489, GJ627, 0002489,
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 16 Feb 2020 21:32:19 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2020-02-16T21:32:19Z</dc:date>
    <item>
      <title>How to create NewIDs based on Macro IDs list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625145#M184239</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a data X which contains macro ID list, and I have a Sample dataset Y which contains all different kind of formats.&amp;nbsp;&amp;nbsp; I would like to create a NewID (see data Want) &amp;nbsp;based on the macro ID list from TempID_1 to TempID_4 (see data Y).&amp;nbsp;&amp;nbsp; Is there a way to approach this?&amp;nbsp; Thank you.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
format ID $10. ;
input ID $10. ;
cards;
1156
1789
0001147
0001597
0598
0002489
;
run;
 
data y;
      infile datalines dsd;
  input TempID_1 : $15. TempID_2 : $15.  TempID_3 : $15. TempID_4 : $15.;
datalines;
21156, , , ,
, 000-1147, , ,    
, , Car_1597, ,
, , , ID 1789,
C1156, , , ,
, 1789 Car,  , ,
, , ID__0598-Car, ,
200, 9, X1O23, UP689,
2001156, , , ,
, , ,  1597 UP,
208, 9,  8MO23, UV689,
, 8,  HL 2489, GJ627,
;



data want;
	infile datalines dsd;
  input TempID_1 : $15. TempID_2 : $15.  TempID_3 : $15. TempID_4 : $15. NewID : $15. ;
datalines;
21156, , , , 1156,
, 000-1147, , , 000147,   
, , Car_1597, , 0001597,
, , , ID 1789, 1789,
C1156, , , , 1156,
, 1789 Car,  , , 1789,
, , ID__0598-Car, , 0598,
200, 9, X1O23, UP689, ,
2001156, , , , 1156,
, , ,  1597 UP, 0001579,
208, 9,  8MO23, UV689, ,
, 8,  HL 2489, GJ627, 0002489,
;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Feb 2020 21:32:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625145#M184239</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2020-02-16T21:32:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create NewIDs based on Macro IDs list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625157#M184244</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select *
from HAVE2 left join HAVE1
  on cats(of TempID_1-TempID_4) contains put(input(ID,32.),z4.) ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;[Edit: corrected code]&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 09:18:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625157#M184244</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-02-17T09:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to create NewIDs based on Macro IDs list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625191#M184251</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data x;
format ID $10. ;
input ID $10. ;
cards;
1156
1789
0001147
0001597
0598
0002489
;
run;
 
data y;
      infile datalines dsd;
  input TempID_1 : $15. TempID_2 : $15.  TempID_3 : $15. TempID_4 : $15.;
datalines;
21156, , , ,
, 000-1147, , ,    
, , Car_1597, ,
, , , ID 1789,
C1156, , , ,
, 1789 Car,  , ,
, , ID__0598-Car, ,
200, 9, X1O23, UP689,
2001156, , , ,
, , ,  1597 UP,
208, 9,  8MO23, UV689,
, 8,  HL 2489, GJ627,
;

proc sql;
select *
from Y left join X
  on catx('|',TempID_1,TempID_2,TempID_3,TempID_4) contains strip(prxchange('s/^0+//',1,ID)) ;
 quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Feb 2020 06:09:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-NewIDs-based-on-Macro-IDs-list/m-p/625191#M184251</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-02-17T06:09:56Z</dc:date>
    </item>
  </channel>
</rss>

