<?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: Transform multiple ID lines into one in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409130#M99940</link>
    <description>Excellent this worked very well for 2 of the 3 questions. Only one step I still need help For Type. In the column type if there is only one name as house I want a third column as house. If there are more then one observation in type like house and building for the same ID I want to call multiple in the third column.</description>
    <pubDate>Tue, 31 Oct 2017 14:21:38 GMT</pubDate>
    <dc:creator>Giovani</dc:creator>
    <dc:date>2017-10-31T14:21:38Z</dc:date>
    <item>
      <title>Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409101#M99927</link>
      <description>&lt;P&gt;I have a table with multiple ID`s(city) I want to create a new one with one line per ID. Some ID's have more than one information in other columns like for Type and K value, For type, I want to create 2 new columns in the final table. One counting how many different types was inside the original data(example: for city G I would like to have a value of and another; column calling that Type as multiple. For K value I just want to have in the final table a value as sum.&lt;/P&gt;
&lt;PRE&gt;City Type k value 
A House 130 
B Building 405 
C Apartment 155 
D Building 1110 
D House 300 
E Apartment 230 
F Apartment 165 
G Building 2500 
G House 250 
G House 220 
H Apartment 185 
H House 250 
H House 580 
H Apartment 570&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Oct 2017 14:04:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409101#M99927</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T14:04:24Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409104#M99929</link>
      <description>I have a table with multiple ID`s(city) I want to create a new one with one line per ID. Some ID's have more than one information in other columns like for Type and K value, For type, I want to create 2 new columns in the final table. One counting how many different types was inside the original data(example: for city G I would like to have a value of and another; column calling that Type as multiple. For K value I just want to have in the final table a value as sum. ADDED SAMPLE DATA</description>
      <pubDate>Tue, 31 Oct 2017 13:38:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409104#M99929</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T13:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409113#M99932</link>
      <description>&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And provide what the result would look like for any example data. So you need not have all the variables and values just enough to demonstrate the complete process.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 13:58:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409113#M99932</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-31T13:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409115#M99933</link>
      <description>&lt;P&gt;As&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 14:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409115#M99933</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-31T14:03:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409117#M99935</link>
      <description>&lt;P&gt;Sounds like a simple SQL query should get what you want.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as 
  select city
      , count(distinct type) as n_type
      , sum(kvalue) as total_kvalue
  from have
  group by 1
;
quit;   &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Oct 2017 14:09:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409117#M99935</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-31T14:09:15Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409119#M99936</link>
      <description>SAS data model</description>
      <pubDate>Tue, 31 Oct 2017 14:12:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409119#M99936</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T14:12:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409130#M99940</link>
      <description>Excellent this worked very well for 2 of the 3 questions. Only one step I still need help For Type. In the column type if there is only one name as house I want a third column as house. If there are more then one observation in type like house and building for the same ID I want to call multiple in the third column.</description>
      <pubDate>Tue, 31 Oct 2017 14:21:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409130#M99940</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T14:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409133#M99942</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/170866"&gt;@Giovani&lt;/a&gt; wrote:&lt;BR /&gt;Excellent this worked very well for 2 of the 3 questions. Only one step I still need help For Type. In the column type if there is only one name as house I want a third column as house. If there are more then one observation in type like house and building for the same ID I want to call multiple in the third column.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That is as clear as mud.&lt;/P&gt;
&lt;P&gt;Please post what you want as the output dataset. Make sure to use the insert code icon so that the text is not reflowed into paragraphs.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 14:27:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409133#M99942</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-31T14:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409144#M99945</link>
      <description>I want to keep the column Type. If the City has only one information in the column Type I want to keep that information for Type. If the City has more than one information in the column Type I want to call Type as multiple.</description>
      <pubDate>Tue, 31 Oct 2017 14:42:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409144#M99945</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T14:42:46Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409147#M99947</link>
      <description>&lt;P&gt;Try this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  length city type $20 kvalue 8;
  input city type kvalue;
cards;
A House 130 
B Building 405 
C Apartment 155 
D Building 1110 
D House 300 
E Apartment 230 
F Apartment 165 
G Building 2500 
G House 250 
G House 220 
H Apartment 185 
H House 250 
H House 580 
H Apartment 570
;

proc sql ;
create table want as
  select city
       , count(distinct type) as n_type
       , sum(kvalue) as total_kvalue
       , case when (calculated n_type=1) then max(type)
              else 'Multiple'
         end as New_Type
  from have
  group by 1
;
quit;

proc print;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Oct 2017 14:50:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409147#M99947</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-31T14:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Transform multiple ID lines into one</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409149#M99948</link>
      <description>Dear Tom, You are fantastic/awesome! This worked. Thank very much!!!</description>
      <pubDate>Tue, 31 Oct 2017 14:55:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Transform-multiple-ID-lines-into-one/m-p/409149#M99948</guid>
      <dc:creator>Giovani</dc:creator>
      <dc:date>2017-10-31T14:55:52Z</dc:date>
    </item>
  </channel>
</rss>

