<?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: How do I code the possible combinations of 10 variables into an integer variable? in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514661#M2777</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input ID $ Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10;
cards;
1 3 4 5 0 0 0 3 4 1 0
2 1 1 0 0 0 0 2 6 1 4
3 1 1 1 1 0 0 0 7 1 0
;
run;

data want;
set have;
_t = put (0, rb8.) ;
array t(*) q:;
sus_use = dim(t)-count(put(peekclong (addrlong(t[1]), 80), $80.),_t) ;
drop _t;
run;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 20 Nov 2018 04:03:43 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-11-20T04:03:43Z</dc:date>
    <item>
      <title>How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514605#M2763</link>
      <description>&lt;P&gt;Dear SAS users,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using SAS Enterprise Guide to look at use data for an online patient portal. i have counts of use per quarter over 2.5 years (10 quarters). I would like to code this data into an integer that represents how many quarters a patient used the portal at least once. For example, if a patient used the portal&amp;nbsp;at least once for 7 out of the 10 quarters, I would want to code this as a 7, or if the patient only used this portal once for 3 out of the 10 quarters, this would be coded as a 3.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With 10 quarters of data, the amount of combinations possible is exhausting and I'm looking for a code that can automate this process.&lt;/P&gt;&lt;P&gt;My dataset looks similar to this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID	Q1	Q2	Q3	Q4	Q5	Q6	Q7	Q8	Q9	Q10
1	3	4	5	0	0	0	3	4	1	0
2	1	1	0	0	0	0	2	6	1	4
3	1	1	1	1	0	0	0	7	1	0&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far, I have been able to code for all possible combinations of quarters with 1 or more counts using the code below. However, this does not allow me to code the possible combinations as integers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data work.sList;
length sList$200;
array _s Q1 -- Q10;
do i=1 to dim(_sum);
if _s(i) &amp;gt; 0 then sList=catx (" and ", sList, vname (_s{i}));
end;
keep sList ID;
run;

proc sql;
create table sCounts as
select sList, count(*) as nbPat
from sList
group by sList;
quit;&lt;/PRE&gt;&lt;P&gt;Your help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Stephanie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514605#M2763</guid>
      <dc:creator>sarobinson010</dc:creator>
      <dc:date>2018-11-19T22:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514607#M2764</link>
      <description>&lt;P&gt;So what do you expect as output for that input?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would it be 6, 6, 6?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or are you looking for something else?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One way is to convert them all to 0/1s and then use PROC FREQ to summarize it with the LIST option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you clarify what you need as output, I can provide the appropriate code for the specific option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/247383"&gt;@sarobinson010&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear SAS users,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS Enterprise Guide to look at use data for an online patient portal. i have counts of use per quarter over 2.5 years (10 quarters). I would like to code this data into an integer that represents how many quarters a patient used the portal at least once. For example, if a patient used the portal&amp;nbsp;at least once for 7 out of the 10 quarters, I would want to code this as a 7, or if the patient only used this portal once for 3 out of the 10 quarters, this would be coded as a 3.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With 10 quarters of data, the amount of combinations possible is exhausting and I'm looking for a code that can automate this process.&lt;/P&gt;
&lt;P&gt;My dataset looks similar to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ID	Q1	Q2	Q3	Q4	Q5	Q6	Q7	Q8	Q9	Q10
1	3	4	5	0	0	0	3	4	1	0
2	1	1	0	0	0	0	2	6	1	4
3	1	1	1	1	0	0	0	7	1	0&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far, I have been able to code for all possible combinations of quarters with 1 or more counts using the code below. However, this does not allow me to code the possible combinations as integers.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data work.sList;
length sList$200;
array _s Q1 -- Q10;
do i=1 to dim(_sum);
if _s(i) &amp;gt; 0 then sList=catx (" and ", sList, vname (_s{i}));
end;
keep sList ID;
run;

proc sql;
create table sCounts as
select sList, count(*) as nbPat
from sList
group by sList;
quit;&lt;/PRE&gt;
&lt;P&gt;Your help is greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best,&lt;/P&gt;
&lt;P&gt;Stephanie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514607#M2764</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-19T22:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514613#M2768</link>
      <description>&lt;P&gt;Dear Reeza,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your reply. Yes,&amp;nbsp;based on the example data I posted, I would want to code for a new variable to represent "sustained use" (sus_use), as in this example below. I hope that clarification is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Stephanie&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ID	Q1	Q2	Q3	Q4	Q5	Q6	Q7	Q8	Q9	Q10	  Sus_use
1	3	4	5	0	0	0	3	4	1	0         6
2	1	1	0	0	0	0	2	6	1	4         6
3	1	1	1	1	0	0	0	7	1	0         6&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514613#M2768</guid>
      <dc:creator>sarobinson010</dc:creator>
      <dc:date>2018-11-19T22:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514615#M2769</link>
      <description>&lt;P&gt;Ok. I think coding to 0/1 would be helpful here. Then you can use the SUM function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;You didn't have a SET statement,&lt;/STRONG&gt; you most likely do need one.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check the WANT and WANT_SUMMARY output data sets as well - they'll be in the work library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.sList;

SET &amp;lt;Source data&amp;gt;;

array _Quest(*) Q1 - Q10;
array _d(*) d1-d10;

sus_use=0;

do i=1 to dim(_Quest);
if _quest(i) &amp;gt; 0 then _d(i)=1;
else _d(i)=0;
end;

sus_use = sum(of D1-D10);

keep ID sus_use;
run;


proc freq data=sList noprint;
table D1*D2*D3*D4*D5*D6*D7*D8*D9*D10 / out=want list;
table sus_use / out=want_Summary;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/247383"&gt;@sarobinson010&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Dear Reeza,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your reply. Yes,&amp;nbsp;based on the example data I posted, I would want to code for a new variable to represent "sustained use" (sus_use), as in this example below. I hope that clarification is helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Stephanie&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ID	Q1	Q2	Q3	Q4	Q5	Q6	Q7	Q8	Q9	Q10	  Sus_use
1	3	4	5	0	0	0	3	4	1	0         6
2	1	1	0	0	0	0	2	6	1	4         6
3	1	1	1	1	0	0	0	7	1	0         6&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 22:42:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514615#M2769</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-19T22:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514620#M2770</link>
      <description>&lt;P&gt;Is this what you are looking for ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10;
cards;
1 3 4 5 0 0 0 3 4 1 0
2 1 1 0 0 0 0 2 6 1 4
3 1 1 1 1 0 0 0 7 1 0
;
run;

data want;
	set have;
	array qtr q1-q10;
	Sus_use=0;
	do over qtr;
		if qtr &amp;gt; 0 then Sus_use +1;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Nov 2018 23:00:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514620#M2770</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2018-11-19T23:00:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514626#M2772</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;&amp;nbsp;DO OVER is deprecated so it's better to not use it in new programs. Backwards compatibility is maintained at the moment, but that could change.&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/223452"&gt;@r_behata&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Is this what you are looking for ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input ID $ Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10;
cards;
1 3 4 5 0 0 0 3 4 1 0
2 1 1 0 0 0 0 2 6 1 4
3 1 1 1 1 0 0 0 7 1 0
;
run;

data want;
	set have;
	array qtr q1-q10;
	Sus_use=0;
	do over qtr;
		if qtr &amp;gt; 0 then Sus_use +1;
	end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 23:17:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514626#M2772</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-19T23:17:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514637#M2773</link>
      <description>&lt;P&gt;This is exactly what I was looking for, thank you so much. Making each quarter dichotomous (0 or 1) and the summing across the quarters in hindsight seems like such a simple fix.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You've been a great help. Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stephanie&lt;/P&gt;</description>
      <pubDate>Mon, 19 Nov 2018 23:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514637#M2773</guid>
      <dc:creator>sarobinson010</dc:creator>
      <dc:date>2018-11-19T23:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I code the possible combinations of 10 variables into an integer variable?</title>
      <link>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514661#M2777</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have;
input ID $ Q1 Q2 Q3 Q4 Q5 Q6 Q7 Q8 Q9 Q10;
cards;
1 3 4 5 0 0 0 3 4 1 0
2 1 1 0 0 0 0 2 6 1 4
3 1 1 1 1 0 0 0 7 1 0
;
run;

data want;
set have;
_t = put (0, rb8.) ;
array t(*) q:;
sus_use = dim(t)-count(put(peekclong (addrlong(t[1]), 80), $80.),_t) ;
drop _t;
run;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 20 Nov 2018 04:03:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/How-do-I-code-the-possible-combinations-of-10-variables-into-an/m-p/514661#M2777</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-11-20T04:03:43Z</dc:date>
    </item>
  </channel>
</rss>

