<?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: Automated query of a subgroup with generation of the total value for the subgroup in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867965#M342810</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id subid         side ;
cards; 
1 1  1 
1 2  2 
1 3  2 
2 1  2 
2 2  0 
3 1  1 
3 2  0 
3 3  1 
3 4  1 
3 5  1 
4 1  0 
5 1  1
;

proc sql;
create table want as
select *,
case
 when sum(side=0)=count(*) then 0
 when sum(side=1)=count(*) then 1
 when sum(side=2)=count(*) then 2
 when sum(side in (1 2))=count(*) then 3
 when sum(side in (1 0))=count(*) then 4
 when sum(side in (2 0))=count(*) then 5
 when sum(side in (2 0 1))=count(*) then 6
 else .
end as var1,
case
 when sum(side=0)=count(*) then 'no value'
 when sum(side=1)=count(*) then 'one sided left'
 when sum(side=2)=count(*) then 'one sided right'
 when sum(side in (1 2))=count(*) then 'both sides'
 when sum(side in (1 0))=count(*) then 'one sided left and no value'
 when sum(side in (2 0))=count(*) then 'one sided right and no value'
 when sum(side in (2 0 1))=count(*) then 'both sides and no value'
 else ' '
end as want length=40
 from have
  group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 Apr 2023 12:10:22 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-04-04T12:10:22Z</dc:date>
    <item>
      <title>Automated query of a subgroup with generation of the total value for the subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867918#M342790</link>
      <description>&lt;P&gt;Dear SAS Community,&lt;/P&gt;&lt;P&gt;I have the following problem to solve. I have a data set in which the informations about the measurement sides are stored. The data set looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;id	subid	        side	        var1
1	1		1		3
1	2		2		3
1	3		2		3
2	1		2		5
2	2		0		5
3	1		1		4
3	2		0		4
3	3		1		4
3	4		1		4
3	5		1		4
4	1		0		0
5	1		1		1


Side 
0=no value
1=left
2=right

var1
0=no value
1=one sided left
2=one sided right
3=both sides
4=one sided left and no value
5=one sided right and no value
6=both sides and no value&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I automate the function to query all the values of the variable "Side" and then save the result according to the attached coding for the total group.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 07:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867918#M342790</guid>
      <dc:creator>Zakharkou</dc:creator>
      <dc:date>2023-04-04T07:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: Automated query of a subgroup with generation of the total value for the subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867925#M342794</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;not really clear to me what you want to achieve.&lt;/P&gt;
&lt;P&gt;Here's my best try using your description&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC FORMAT;
   VALUE Side 
      0='no value'
      1='left'
      2='right'
   ;
   VALUE var1_
      0='no value'
      1='one sided left'
      2='one sided right'
      3='both sides'
      4='one sided left and no value'
      5='one sided right and no value'
      6='both sides and no value'
   ;
run;

DATA have;
INPUT id	subid side var1;
FORMAT side side. var1 var1_.;
DATALINES;
1	1		1		3
1	2		2		3
1	3		2		3
2	1		2		5
2	2		0		5
3	1		1		4
3	2		0		4
3	3		1		4
3	4		1		4
3	5		1		4
4	1		0		0
5	1		1		1
;
RUN;

PROC SQL;
   CREATE TABLE want AS
      SELECT DISTINCT side,var1
      FROM have
      ORDER BY side,var1
   ;
QUIT;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 07:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867925#M342794</guid>
      <dc:creator>Oligolas</dc:creator>
      <dc:date>2023-04-04T07:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Automated query of a subgroup with generation of the total value for the subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867934#M342798</link>
      <description>&lt;P&gt;The issue is that I need to create the variable "var1" according to the above description. Unfortunately the var1 is not present.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 08:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867934#M342798</guid>
      <dc:creator>Zakharkou</dc:creator>
      <dc:date>2023-04-04T08:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Automated query of a subgroup with generation of the total value for the subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867965#M342810</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input id subid         side ;
cards; 
1 1  1 
1 2  2 
1 3  2 
2 1  2 
2 2  0 
3 1  1 
3 2  0 
3 3  1 
3 4  1 
3 5  1 
4 1  0 
5 1  1
;

proc sql;
create table want as
select *,
case
 when sum(side=0)=count(*) then 0
 when sum(side=1)=count(*) then 1
 when sum(side=2)=count(*) then 2
 when sum(side in (1 2))=count(*) then 3
 when sum(side in (1 0))=count(*) then 4
 when sum(side in (2 0))=count(*) then 5
 when sum(side in (2 0 1))=count(*) then 6
 else .
end as var1,
case
 when sum(side=0)=count(*) then 'no value'
 when sum(side=1)=count(*) then 'one sided left'
 when sum(side=2)=count(*) then 'one sided right'
 when sum(side in (1 2))=count(*) then 'both sides'
 when sum(side in (1 0))=count(*) then 'one sided left and no value'
 when sum(side in (2 0))=count(*) then 'one sided right and no value'
 when sum(side in (2 0 1))=count(*) then 'both sides and no value'
 else ' '
end as want length=40
 from have
  group by id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Apr 2023 12:10:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867965#M342810</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-04-04T12:10:22Z</dc:date>
    </item>
    <item>
      <title>Re: Automated query of a subgroup with generation of the total value for the subgroup</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867988#M342822</link>
      <description>It work great, thank You very much!!!</description>
      <pubDate>Tue, 04 Apr 2023 13:40:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Automated-query-of-a-subgroup-with-generation-of-the-total-value/m-p/867988#M342822</guid>
      <dc:creator>Zakharkou</dc:creator>
      <dc:date>2023-04-04T13:40:09Z</dc:date>
    </item>
  </channel>
</rss>

