<?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: Concetenating Checkbox Options i in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/823172#M81931</link>
    <description>&lt;P&gt;Used the first part of your data to demo the process I would take to label the checkbox values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length chks $ 10;
	input chks $;
	datalines;
1,2
1
1,2,3
1,2,4
1,3
1,4
1,4,3
1,5
2
2,3
2,4
2,5
2,6
;
proc format;
	value $status 1='Admitted' 2='Discharged' 
				  3='Transferred' 4='Left AMA' 
				  5='Expired' 6='Unknown' 7='Eloped';
run;

data want;
	set have;
	length parse $12 status_ednf_nnf1  $500;

	do i=1 by 1 until (parse='');
		parse=put(scan(chks, i, ','),$status.);

		if i=1 then
			status_ednf_nnf1=parse;
		else
			status_ednf_nnf1=catx(',', status_ednf_nnf1, parse);
	end;
	keep chks status_ednf_nnf1 ;
run;
proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ghosh_0-1657731378953.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73277i4156872F3D515D21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ghosh_0-1657731378953.png" alt="ghosh_0-1657731378953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Jul 2022 16:57:23 GMT</pubDate>
    <dc:creator>ghosh</dc:creator>
    <dc:date>2022-07-13T16:57:23Z</dc:date>
    <item>
      <title>Concetenating Checkbox Options i</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/821708#M81914</link>
      <description>&lt;P&gt;Hello- this is my first post in this community and hoping for some help, if I need to adjust anything about my style of posting, please let me know and I will adjust!&lt;BR /&gt;I am working with a healthcare dataset that involves many variables (some char, some numeric) that represent checkboxes in a database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;For example, one would tick off all the applicable options&amp;nbsp;to capture what outcome a patient may have ( 1 being Admitted, 2 being Discharged, etc.).&lt;BR /&gt;I am trying to produce simple frequency counts for each option ( 406 patients were Admitted, 189 patients were Discharged etc. ) and have made formats to convert each number into the corresponding character string.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;However, observations that have more than one option chosen don't apply the format (if a patient was Transferred then Discharged, and both options were chosen, outputs as '2,5' not 'Transferred,Discharged'). I was thinking of using PRXMATCH to pick up instances of each number and creating secondary accumulating variables for each option, but am not sure thats most efficient . I've attached screenshots of the resulting frequency tables, and copy &amp;amp; pasted my code. Any guidance would be appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/***************************************************/&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc format;&lt;BR /&gt;value $status 1='Admitted' 2='Discharged'&lt;BR /&gt;3='Transferred' 4='Left AMA' 5='Expired'&lt;BR /&gt;6='Unknown' 7='Eloped';&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc freq data=nonfatal.final;&lt;BR /&gt;format status_ednf_nnf1 $status.;&lt;BR /&gt;tables status_ednf_nnf1;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/*******************************/&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="lele619111_1-1657052184158.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72964i5545F71140893205/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lele619111_1-1657052184158.png" alt="lele619111_1-1657052184158.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="lele619111_2-1657052197773.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72965iCA5AD478E3AF9162/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lele619111_2-1657052197773.png" alt="lele619111_2-1657052197773.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 20:25:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/821708#M81914</guid>
      <dc:creator>lele619111</dc:creator>
      <dc:date>2022-07-05T20:25:56Z</dc:date>
    </item>
    <item>
      <title>Re: Concetenating Checkbox Options i</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/821719#M81915</link>
      <description>&lt;P&gt;You need to convert them &lt;U&gt;&lt;STRONG&gt;before&lt;/STRONG&gt; &lt;/U&gt;you concatenate them.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately there isn't a concatenation operator which handles this, so you need to loop through via an array.&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;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jul 2022 21:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/821719#M81915</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-07-05T21:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Concetenating Checkbox Options i</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/823049#M81929</link>
      <description>&lt;P&gt;By using tranwrd function, we can get the results in&amp;nbsp;desired way. Please follow below code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data sam;
length x $10;
x="1";output;
x="2,3";output;
x="1,3";output;
x="2";output;
x="1,2,3";output;
x="1,3";output;
x="2,3";output;
x="3";output;
; 
run;

data fin;
length word $100;
set sam;
word=x;
word=tranwrd(word,"1","Admitted");
word=tranwrd(word,"2","Treated");
word=tranwrd(word,"3","Discharged");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jul 2022 05:35:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/823049#M81929</guid>
      <dc:creator>kleelasiva9</dc:creator>
      <dc:date>2022-07-13T05:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Concetenating Checkbox Options i</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/823172#M81931</link>
      <description>&lt;P&gt;Used the first part of your data to demo the process I would take to label the checkbox values&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	length chks $ 10;
	input chks $;
	datalines;
1,2
1
1,2,3
1,2,4
1,3
1,4
1,4,3
1,5
2
2,3
2,4
2,5
2,6
;
proc format;
	value $status 1='Admitted' 2='Discharged' 
				  3='Transferred' 4='Left AMA' 
				  5='Expired' 6='Unknown' 7='Eloped';
run;

data want;
	set have;
	length parse $12 status_ednf_nnf1  $500;

	do i=1 by 1 until (parse='');
		parse=put(scan(chks, i, ','),$status.);

		if i=1 then
			status_ednf_nnf1=parse;
		else
			status_ednf_nnf1=catx(',', status_ednf_nnf1, parse);
	end;
	keep chks status_ednf_nnf1 ;
run;
proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ghosh_0-1657731378953.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/73277i4156872F3D515D21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ghosh_0-1657731378953.png" alt="ghosh_0-1657731378953.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2022 16:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Concetenating-Checkbox-Options-i/m-p/823172#M81931</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2022-07-13T16:57:23Z</dc:date>
    </item>
  </channel>
</rss>

