<?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: separating out multiple response survey data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872572#M344728</link>
    <description>&lt;P&gt;You need to separate distinct values into a new row first, then use proc freq to get frequency of categories.&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
	set have;
	num= countc(Referral_Sevice, ',');
	if num=0 then do;
		Services= strip(Referral_Sevice);
		output;
	end;
	else do i=1 to num+1;
		Services= scan(Referral_Sevice, i, ',');
		output;
	end;
proc print;run;
 
proc freq data=have1;
	tables services/nocol norow nocum out=want(rename=(count=n));
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 469px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83333i10D61044CD14CBF9/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;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 27 Apr 2023 13:34:05 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2023-04-27T13:34:05Z</dc:date>
    <item>
      <title>separating out multiple response survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872438#M344696</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have free response data that looks like this&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="393310_0-1682568618680.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83275iADF4E3A061AB8853/image-size/medium?v=v2&amp;amp;px=400" role="button" title="393310_0-1682568618680.png" alt="393310_0-1682568618680.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I want to calculate the frequency and percent of each of the individual services but I'm not sure how I can separate this out easily?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I use the if find statement, I can create separate columns, but wouldn't be able to calculate the percent.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone help me with this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;I want&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;referral service&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;N&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;%&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Alternative&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;10&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;CBT&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;14&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;7%&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 04:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872438#M344696</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2023-04-27T04:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: separating out multiple response survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872572#M344728</link>
      <description>&lt;P&gt;You need to separate distinct values into a new row first, then use proc freq to get frequency of categories.&lt;/P&gt;
&lt;P&gt;eg:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
	set have;
	num= countc(Referral_Sevice, ',');
	if num=0 then do;
		Services= strip(Referral_Sevice);
		output;
	end;
	else do i=1 to num+1;
		Services= scan(Referral_Sevice, i, ',');
		output;
	end;
proc print;run;
 
proc freq data=have1;
	tables services/nocol norow nocum out=want(rename=(count=n));
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 469px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/83333i10D61044CD14CBF9/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;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 13:34:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872572#M344728</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-04-27T13:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: separating out multiple response survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872610#M344740</link>
      <description>THANK YOU!!</description>
      <pubDate>Thu, 27 Apr 2023 16:57:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/872610#M344740</guid>
      <dc:creator>393310</dc:creator>
      <dc:date>2023-04-27T16:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: separating out multiple response survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/906645#M357994</link>
      <description>&lt;P&gt;Is there a way to create a macro/loop to do this for multiple responses for multiple variables? Trying to do this right now but for multiple variables, any help would be super appreciated!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Dec 2023 03:09:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/906645#M357994</guid>
      <dc:creator>khaque2</dc:creator>
      <dc:date>2023-12-07T03:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: separating out multiple response survey data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/906702#M358011</link>
      <description>&lt;P&gt;Yes, the program can be used inside a macro using loop to reference multiple variables sequentially.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the below example which creates a macro parameter 'freqvars' referencing to multiple variables, then creates a macro variable 'freqvar' referencing to an individual variable (out of multiple variables)&amp;nbsp; and processes each variable in a loop in the order they are referenced in macro parameter (freqvars=). This macro creates datasets for each variable with frequency of categories.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro freqs(freqvars=); 
	%do i= 1 %to %sysfunc(countw(&amp;amp;freqvars)); 
		%let freqvar= %scan(&amp;amp;freqvars, &amp;amp;i);
		data have1;
			set have;
			num= countc(&amp;amp;freqvar, ',');
			if num=0 then do;
				Services= strip(&amp;amp;freqvar);
				output;
			end;
			else do i=1 to num+1;
				Services= scan(&amp;amp;freqvar, i, ',');
				output;
			end;
		run;
		proc freq data=have1;
			tables services/nocol norow nocum out=&amp;amp;freqvar(rename=(count=n));
		run;
	%end; 
%mend;

%freqs(freqvars= Referral_Sevice VAR2 VAR3 ... VARn); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Dec 2023 14:08:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/separating-out-multiple-response-survey-data/m-p/906702#M358011</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-12-07T14:08:54Z</dc:date>
    </item>
  </channel>
</rss>

