<?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: From long format to short data format in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953515#M42862</link>
    <description>&lt;P&gt;This will work for the example data:&lt;/P&gt;
&lt;PRE&gt;data work.db1;
   set work.db;
   array c (*) class1-class4;
   c[class]=value;
   drop value;
run;&lt;/PRE&gt;
&lt;P&gt;Arrays are a way of referencing, usually related, variables using one or more numeric index variables. The ARRAY statement creates the reference. Because you already have a variable named Class we couldn't use that as a name so list the names you wanted. The index is placed in parentheses after the array name. I use the [ ] as a style choice to remind myself this is an array.&lt;/P&gt;
&lt;P&gt;Arrays can only hold variables of the same type, no mixing numeric and character.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 16:08:19 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-12-13T16:08:19Z</dc:date>
    <item>
      <title>From long format to short data format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953512#M42861</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Admission :date09. Discharge :date09. Class Value; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 2  0.32
0001 21FEB2015 31DEC2015 2  0.32
0001 01MAR2018 30SEP2018 3  0.43
0001 01JAN2019 31DEC2019 3  0.43
0002 01JAN2015 31DEC2015 2  1.92
0002 01JAN2019 31OCT2019 2  1.92
0003 08FEB2014 10MAR2014 1  4.32
0003 16JUN2015 13JUL2015 1  4.32
0004 04MAY2016 10MAY2016 3  3.22
0004 13SEP2017 15NOV2017 3  3.22
0004 09DEC2018 31DEC2018 3  3.22
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a way to get the following?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data DB1;
  input ID :$20. Admission :date09. Discharge :date09. Class Class1 Class2 Class3 Class4; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 2   .   0.32   .     .
0001 21FEB2015 31DEC2015 2   .   0.32   .     .
0001 01MAR2018 30SEP2018 3   .     .   0.43   .
0001 01JAN2019 31DEC2019 3   .     .   0.43   .
0002 01JAN2015 31DEC2015 2   .   1.92   .     .
0002 01JAN2019 31OCT2019 2   .   1.92   .     .
0003 08FEB2014 10MAR2014 1  4.32   .    .     .
0003 16JUN2015 13JUL2015 1  4.32   .    .     .
0004 04MAY2016 10MAY2016 3   .     .  3.22    .
0004 13SEP2017 15NOV2017 3   .     .  3.22    .
0004 09DEC2018 31DEC2018 3   .     .  3.22    .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In other words I would like to "distribute" the values of variable "Value" across all classes in Class variable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 15:54:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953512#M42861</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2024-12-13T15:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: From long format to short data format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953515#M42862</link>
      <description>&lt;P&gt;This will work for the example data:&lt;/P&gt;
&lt;PRE&gt;data work.db1;
   set work.db;
   array c (*) class1-class4;
   c[class]=value;
   drop value;
run;&lt;/PRE&gt;
&lt;P&gt;Arrays are a way of referencing, usually related, variables using one or more numeric index variables. The ARRAY statement creates the reference. Because you already have a variable named Class we couldn't use that as a name so list the names you wanted. The index is placed in parentheses after the array name. I use the [ ] as a style choice to remind myself this is an array.&lt;/P&gt;
&lt;P&gt;Arrays can only hold variables of the same type, no mixing numeric and character.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 16:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953515#M42862</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-12-13T16:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: From long format to short data format</title>
      <link>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953580#M42865</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data DB;
  input ID :$20. Admission :date09. Discharge :date09. Class Value; 
  format Admission date9. Discharge date9.;
cards;
0001 13JAN2015 20JAN2015 2  0.32
0001 21FEB2015 31DEC2015 2  0.32
0001 01MAR2018 30SEP2018 3  0.43
0001 01JAN2019 31DEC2019 3  0.43
0002 01JAN2015 31DEC2015 2  1.92
0002 01JAN2019 31OCT2019 2  1.92
0003 08FEB2014 10MAR2014 1  4.32
0003 16JUN2015 13JUL2015 1  4.32
0004 04MAY2016 10MAY2016 3  3.22
0004 13SEP2017 15NOV2017 3  3.22
0004 09DEC2018 31DEC2018 3  3.22
;
proc sort data=db;
by id Admission Discharge class;
run;
proc transpose data=db prefix=class out=want(drop=_name_);
by id Admission Discharge class;
var value;
id class;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Dec 2024 08:24:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/From-long-format-to-short-data-format/m-p/953580#M42865</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-14T08:24:33Z</dc:date>
    </item>
  </channel>
</rss>

