<?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: New data set creation by ID and all data in one row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429328#M106041</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156990"&gt;@librasantosh&lt;/a&gt;&amp;nbsp;Until you clarify , some fun:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id	Expense_day : date7.	Expens_type $	Expense;
format  Expense_day date7.;
datalines;
1	7-May-05	a	4.2
1	19-May-05	a	4.7
1	20-May-05	a	3.1
1	22-May-05	a	4.1
1	16-Jun-05	a	6.5
1	22-Jun-05	a	3.8
1	30-Jun-05	a	4.8
1	16-Jul-05	a	4.4
1	24-Jul-05	a	1.1
1	26-Jul-05	b	6.6
1	7-Aug-05	b	2.6
1	20-Aug-05	b	1.2
2	23-Aug-05	a	2.4
2	26-Sep-05	a	4.8
2	22-Oct-05	a	1.3
2	24-Oct-05	a	1.5
2	6-Nov-05	a	27.4
2	10-Nov-05	b	4.9
2	14-Nov-05	b	1.4
2	26-Nov-05	b	1.7
;
data want;
do until(last.id);
set have;
by id;
_month=month(Expense_day);
end;
call missing(_t);
do until(last.id);
set have;
by id;
if month(Expense_day)&amp;gt;=_month-3+1 then _t+Expense;
end;
mon3_a_avg_amt=divide(_t,3);
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 19 Jan 2018 23:50:11 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-19T23:50:11Z</dc:date>
    <item>
      <title>New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429316#M106034</link>
      <description>&lt;P&gt;Hi attached is dataset sample. I want to get dataset for id 1 have all info in one row. Also want to create variable how much expenses for id 1 in last 3 month for expense _type,&amp;nbsp; &amp;nbsp;3m_a_avg_amt.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 23:26:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429316#M106034</guid>
      <dc:creator>librasantosh</dc:creator>
      <dc:date>2018-01-19T23:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429323#M106037</link>
      <description>&lt;P&gt;sounds like a simple transpose after where id=1 and loop through for the last 3 months.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What should your result look like? There is no output sample&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 23:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429323#M106037</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-19T23:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429327#M106040</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;Do you want a data set (input to other processes) or a report (people will read)?&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jan 2018 23:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429327#M106040</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-19T23:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429328#M106041</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156990"&gt;@librasantosh&lt;/a&gt;&amp;nbsp;Until you clarify , some fun:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data have;
input id	Expense_day : date7.	Expens_type $	Expense;
format  Expense_day date7.;
datalines;
1	7-May-05	a	4.2
1	19-May-05	a	4.7
1	20-May-05	a	3.1
1	22-May-05	a	4.1
1	16-Jun-05	a	6.5
1	22-Jun-05	a	3.8
1	30-Jun-05	a	4.8
1	16-Jul-05	a	4.4
1	24-Jul-05	a	1.1
1	26-Jul-05	b	6.6
1	7-Aug-05	b	2.6
1	20-Aug-05	b	1.2
2	23-Aug-05	a	2.4
2	26-Sep-05	a	4.8
2	22-Oct-05	a	1.3
2	24-Oct-05	a	1.5
2	6-Nov-05	a	27.4
2	10-Nov-05	b	4.9
2	14-Nov-05	b	1.4
2	26-Nov-05	b	1.7
;
data want;
do until(last.id);
set have;
by id;
_month=month(Expense_day);
end;
call missing(_t);
do until(last.id);
set have;
by id;
if month(Expense_day)&amp;gt;=_month-3+1 then _t+Expense;
end;
mon3_a_avg_amt=divide(_t,3);
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 19 Jan 2018 23:50:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/429328#M106041</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-19T23:50:11Z</dc:date>
    </item>
    <item>
      <title>Re: New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/430198#M106343</link>
      <description>Thank you so much</description>
      <pubDate>Tue, 23 Jan 2018 22:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/430198#M106343</guid>
      <dc:creator>librasantosh</dc:creator>
      <dc:date>2018-01-23T22:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: New data set creation by ID and all data in one row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/430272#M106358</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/156990"&gt;@librasantosh&lt;/a&gt;&amp;nbsp;is that what you really you wanted?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2018 03:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/New-data-set-creation-by-ID-and-all-data-in-one-row/m-p/430272#M106358</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-24T03:50:00Z</dc:date>
    </item>
  </channel>
</rss>

