<?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: Remove macro list text strings and appending them to specific columns? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Remove-macro-list-text-strings-and-appending-them-to-specific/m-p/733898#M228682</link>
    <description>&lt;P&gt;Does anyone how to approach the last step?&amp;nbsp; Thank you.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 19:27:27 GMT</pubDate>
    <dc:creator>ybz12003</dc:creator>
    <dc:date>2021-04-14T19:27:27Z</dc:date>
    <item>
      <title>Remove macro list text strings and appending them to specific columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-macro-list-text-strings-and-appending-them-to-specific/m-p/733897#M228681</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a sample set, Datain, as shown below.&amp;nbsp; Column 'Diagnosis' contains various names.&lt;/P&gt;
&lt;PRE&gt;data Datain;
      infile datalines delimiter='/';
  input Diagnosis : $300.  AIRWAY_sp : $200. ENDO_sp : $200.   GENE_sp : $200. ;
datalines;
	CLEFT PALETTE, HYPOTHYROIDISM, CHRONIC RHINITIS / LARYNGOMALACIA,TEF / / /
	HAVING A GTUBE, BILATERAL POLYCYSTIC OVARIAN SYNDROME, AUTISM/ / / /
	VACTERL ASSOCIATION, TRACHEOESOPHAGEAL FISTULA, TEF / / / /
	AUTISM SPECTRUM, SPEECH &amp;amp; COGNITIVE DELAY, BECKWITH / / / METABOLIC DISEASE /
;
run;&lt;/PRE&gt;
&lt;P&gt;I have three different classes, AIRWAY, ENDO, and GENE.&amp;nbsp;&amp;nbsp; Each class includes different disease names as shown below.&lt;/P&gt;
&lt;PRE&gt;/* AIRWAY Class */
data AIRWAY_class;
  infile datalines dsd;
  input  Name : $150. ;
datalines; 
	CLEFT PALETTE,
	LARYNGOMALACIA,
	INEFFECTIVE AIRWAY CLEARAN,
	TRACHEOESOPHAGEAL FISTULA,
	TEF
	;
run;

proc sql noprint;
	select trim(name) into : AIRWAY_Name separated by '|' from AIRWAY_class;
quit;
%put &amp;amp;AIRWAY_Name;

/* ENDO Class */
data ENDO_class;
  infile datalines dsd;
  input  Name : $150. ;
datalines;
	BILATERAL POLYCYSTIC OVARIAN SYNDROME,
	HYPOTHYROIDISM,
	PANCREATIC INSUFFICIENCY,
	PANHYPOPITUITARISM
	;
run;

proc sql noprint;
	select trim(name) into : ENDO_Name separated by '|' from ENDO_class;
quit;
%put &amp;amp;ENDO_Name;

/* GENE Class */
data GENE_class;
  infile datalines dsd;
  input  Name : $150. ;
datalines;
	BECKWITH,
	METABOLIC DISEASE
	VACTERL ASSOCIATION
	;
run;

proc sql noprint;
	select trim(name) into : GENE_Name separated by '|' from GENE_class;
quit;
%put &amp;amp;GENE_Name;
&lt;/PRE&gt;
&lt;P&gt;My first step is&amp;nbsp;assigning the&amp;nbsp;relate&amp;nbsp;class&amp;nbsp;based on the macro above to create a matching class column, as shown below.&lt;/P&gt;
&lt;PRE&gt;/**** Data transform and create class column ****************/
data Dataout1;
	set Datain;
	Diagnosis2 = prxchange("s/[^,]*(&amp;amp;AIRWAY_Name.)[^,]*/AIRWAY/i",              -1, Diagnosis); 
	Diagnosis3 = prxchange("s/[^,]*(&amp;amp;ENDO_Name.)[^,]*/ENDO/i",              -1, Diagnosis2);
	Diagnosis4 = prxchange("s/[^,]*(&amp;amp;GENE_Name.)[^,]*/GENE/i",              -1, Diagnosis3);
	Diagnosis5 = prxchange('s/,(\w)/, \1/',                          -1, Diagnosis4);
	Diagnosis_update = Diagnosis5;
	Drop Diagnosis2-Diagnosis5;

	array vars airway endo gene;
    do over vars;
        if find(Diagnosis_update,vname(vars),"i") then vars=1;
    end;

run;
&lt;/PRE&gt;
&lt;P&gt;My next step is removing the disease names in the above&amp;nbsp;macro list from the column 'Diagnosis,' and appending them to the matching class_sp columns.&amp;nbsp;&amp;nbsp;&amp;nbsp;Please see the details is&amp;nbsp;show the 'Diagnosis_update', 'AIRWAY_sp', 'ENDO_sp', and 'GENE_sp', in the dataset 'Want.'&lt;/P&gt;
&lt;PRE&gt;data Want;
      infile datalines delimiter='/';
  	input Diagnosis : $300.  AIRWAY  AIRWAY_sp : $200. ENDO  ENDO_sp : $200. GENE  GENE_sp : $200. Diagnosis_update : $200. ;
datalines;
	CLEFT PALETTE, HYPOTHYROIDISM, CHRONIC RHINITIS / 1 / LARYNGOMALACIA, TEF, CLEFT PALETTE / 1 / HYPOTHYROIDISM / 0 / / CHRONIC RHINITIS /
	HAVING A GTUBE, BILATERAL POLYCYSTIC OVARIAN SYNDROME, AUTISM/ 0 / / 1 / BILATERAL POLYCYSTIC OVARIAN SYNDROME / 0 / / HAVING A GTUBE, AUTISM /
	VACTERL ASSOCIATION, TRACHEOESOPHAGEAL FISTULA, TEF / 1 / TRACHEOESOPHAGEAL FISTULA, TEF / 1 / VACTERL ASSOCIATION / 0 /  /  /
	AUTISM SPECTRUM, SPEECH &amp;amp; COGNITIVE DELAY, BECKWITH / 0 / / 0 / / 1 / METABOLIC DISEASE, BECKWITH / AUTISM SPECTRUM, SPEECH &amp;amp; COGNITIVE DELAY /
;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 19:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-macro-list-text-strings-and-appending-them-to-specific/m-p/733897#M228681</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2021-04-14T19:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Remove macro list text strings and appending them to specific columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Remove-macro-list-text-strings-and-appending-them-to-specific/m-p/733898#M228682</link>
      <description>&lt;P&gt;Does anyone how to approach the last step?&amp;nbsp; Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 19:27:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Remove-macro-list-text-strings-and-appending-them-to-specific/m-p/733898#M228682</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2021-04-14T19:27:27Z</dc:date>
    </item>
  </channel>
</rss>

