<?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: Collapsing data? Simple Data management &amp;quot;next steps&amp;quot; questions! in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281052#M8004</link>
    <description>&lt;P&gt;Thanks Kurt!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually couldn't figure out where the comma was left out. I tried many variations of your code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just so I can learn, where should the comma have been? It looks identical to the code I used in terms of syntax the only difference being I used the word DISTINCT. I thought maybe this was why you code wasn't working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 29 Jun 2016 12:20:55 GMT</pubDate>
    <dc:creator>christinagting0</dc:creator>
    <dc:date>2016-06-29T12:20:55Z</dc:date>
    <item>
      <title>Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280789#M7992</link>
      <description>&lt;P&gt;New to SAS and would appreciate advice and help on how best to handle this data mangement situation.&lt;/P&gt;&lt;P&gt;I have a dataset in which each observation represents a client. Each client has a "description" variable which could include either a comprehensive assessment, treatment or discharge. I have created 3 new variables to flag each observation if they contain one of these.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example:&lt;/P&gt;&lt;P&gt;treat_yes = 1 if description contains "tx", "treatment" dc_yes = 1 if description contains "dc", "d/c" or "discharge" ca_yes = 1 if desciption contains "comprehensive assessment" or "ca" or "comprehensive ax"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My end goal is to have a new dataset of clients that have gone through a Comprehensive Assessment, Treatment and Discharge.&lt;/P&gt;&lt;P&gt;I'm a little stumped as to what my next move should be here. I have all my variables flagged for clients. But there could be duplicate observations just because a client could have come in many times. So for example:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Client_id    treatment_yes    ca_yes   dc_yes
1234               0            1        1
1234               1            0        0
1234               1            0        1&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;All I really care about is if for a particular client the variables treatment_yes, ca_yes and dc_yes DO NOT equal 0 (i.e., they each have at least one "1". They could have more than one "1" but as long as they are flagged at least once).&lt;/P&gt;&lt;P&gt;I was thinking my next step might be to collapse the data (how do you do this?) for each unique client ID and sum treatment_yes, dc_yes and ca_yes for each client.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If so, how the heck do I accomplish this? Where do I start?&lt;/P&gt;&lt;P&gt;thanks everyone&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 14:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280789#M7992</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-06-28T14:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280794#M7995</link>
      <description>&lt;P&gt;You have a few options.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SQL is a good one, proc means is another.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
Create table want as
Select id, max(treatment_yes) as treatment, max(ca_yes) as ca, max(dc_yes) as dc, sum( calculated treatment, calculated ca, calculated dc) as number_vars
from have
Group by id
Having calculated number_vars=3;
Quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 14:06:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280794#M7995</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-28T14:06:18Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280796#M7997</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    client_id,
    max(treatment_yes) as treatment_yes
    max(ca_yes) as ca_yes,
    max(dc_yes) as dc_yes
  from have
  group by client_id
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 14:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280796#M7997</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-28T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280853#M8000</link>
      <description>&lt;P&gt;Thank you both!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some reason when I was trying both of your proc sql codes I kept on getting a syntax error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I ended up using was this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table temp_collapse as&lt;BR /&gt;select distinct mrn,&lt;BR /&gt;sum(tx_yes) as tx_yes,&lt;BR /&gt;sum(ca_yes) as ca_yes,&lt;BR /&gt;sum(dc_yes) as dc_yes&lt;BR /&gt;from collapsed_data&lt;BR /&gt;group by mrn;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 17:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280853#M8000</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-06-28T17:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280982#M8002</link>
      <description>&lt;P&gt;Yeah, I mistakenly omitted a comma from my code. Comes from not testing &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 06:01:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/280982#M8002</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-29T06:01:46Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281052#M8004</link>
      <description>&lt;P&gt;Thanks Kurt!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually couldn't figure out where the comma was left out. I tried many variations of your code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just so I can learn, where should the comma have been? It looks identical to the code I used in terms of syntax the only difference being I used the word DISTINCT. I thought maybe this was why you code wasn't working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:20:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281052#M8004</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-06-29T12:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281055#M8005</link>
      <description>&lt;P&gt;In my code you would need WHERE instead of HAVING.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281055#M8005</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T12:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281057#M8006</link>
      <description>&lt;P&gt;In SQL, commas are needed to separate members of lists.&lt;/P&gt;
&lt;P&gt;In a select, the elements need to be separated by a comma, but at the end (before the keyword from) there must be no comma, as a different part of the statement begins.&lt;/P&gt;
&lt;P&gt;In my style of writing (every element on its own line) there should be a comma on every line of the select part, with the exception of the last.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281057#M8006</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-29T12:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281060#M8007</link>
      <description>&lt;P&gt;weird...my code didn't require a comma after each select line (as you can see from above in my solution).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyways, thanks very much!&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:32:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281060#M8007</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-06-29T12:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281063#M8008</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/79508"&gt;@christinagting0﻿&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Each item in select statement has a comma except for last.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your solution does have this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281063#M8008</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-06-29T12:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281065#M8009</link>
      <description>&lt;P&gt;From your code snippet:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select distinct mrn,
sum(tx_yes) as tx_yes,
sum(ca_yes) as ca_yes,
sum(dc_yes) as dc_yes&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can see the commas, and the (correctly) missing comma in the last line.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jun 2016 12:39:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281065#M8009</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-06-29T12:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: Collapsing data? Simple Data management "next steps" questions!</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281185#M8012</link>
      <description>thank you!</description>
      <pubDate>Wed, 29 Jun 2016 17:58:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Collapsing-data-Simple-Data-management-quot-next-steps-quot/m-p/281185#M8012</guid>
      <dc:creator>christinagting0</dc:creator>
      <dc:date>2016-06-29T17:58:48Z</dc:date>
    </item>
  </channel>
</rss>

