<?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: how to change the format of dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45951#M12169</link>
    <description>Emmmm.Since you want dataset like that,It needs some more code,and process is much more complicated.&lt;BR /&gt;
See whether it is what you want;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data one;&lt;BR /&gt;
input School $ Month $ StudentName $ Subject $ Test1 Test2 Test3 Test4 Total;&lt;BR /&gt;
datalines;&lt;BR /&gt;
ABC July-10 John Math 90 79 86 99 354&lt;BR /&gt;
ABC July-10 John Science 92 89 99 91 371&lt;BR /&gt;
ABC July-10 John History 78 69 82 79 308&lt;BR /&gt;
ABC July-10 John English 81 79 83 82 325&lt;BR /&gt;
ABC July-10 Becky Math 92 77 76 88 333&lt;BR /&gt;
ABC July-10 Becky Science 67 76 65 83 291&lt;BR /&gt;
ABC July-10 Becky History 78 69 76 79 302&lt;BR /&gt;
ABC July-10 Becky English 90 79 80 81 330&lt;BR /&gt;
ABC Dec-10 John Math 97 93 89 99 378&lt;BR /&gt;
ABC Dec-10 John Science 80 89 92 91 352&lt;BR /&gt;
ABC Dec-10 John History 70 77 76 80 303&lt;BR /&gt;
ABC Dec-10 John English 80 69 78 81 308&lt;BR /&gt;
ABC Dec-10 Becky Math 80 70 67 82 299&lt;BR /&gt;
ABC Dec-10 Becky Science 78 73 66 76 293&lt;BR /&gt;
ABC Dec-10 Becky History 87 77 79 74 317&lt;BR /&gt;
ABC Dec-10 Becky English 79 72 84 81 316&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
 set one;&lt;BR /&gt;
 length _test $ 10;&lt;BR /&gt;
 array test{*} test: total;&lt;BR /&gt;
 do i=1 to dim(test);&lt;BR /&gt;
   _test=vname(test{i});&lt;BR /&gt;
   _value=test{i};&lt;BR /&gt;
   output;&lt;BR /&gt;
 end;&lt;BR /&gt;
 drop test: total i;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=temp;&lt;BR /&gt;
 by _test subject studentname;&lt;BR /&gt;
run;&lt;BR /&gt;
data op;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 by  _test subject studentname;&lt;BR /&gt;
 length _month  value $ 50;&lt;BR /&gt;
 retain _month value;&lt;BR /&gt;
 if first.studentname then call missing (_month ,value);&lt;BR /&gt;
 _month=catx(' ',_month,month);&lt;BR /&gt;
 value=catx(' ',value,_value);&lt;BR /&gt;
 if last.studentname then output;&lt;BR /&gt;
 drop _value month ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
 set op;&lt;BR /&gt;
 length row $ 50;&lt;BR /&gt;
 if _test ne lag(_test) then do;row=_test;output; end;&lt;BR /&gt;
 if subject ne lag(subject) then do;row=catx(' ',subject,_month); output; end;&lt;BR /&gt;
 row=catx(' ',studentname,value);output;&lt;BR /&gt;
 keep row;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Ksharp

Message was edited by: Ksharp</description>
    <pubDate>Fri, 08 Apr 2011 04:16:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-04-08T04:16:43Z</dc:date>
    <item>
      <title>how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45947#M12165</link>
      <description>I want to change the format of the dataset:&lt;BR /&gt;
MY input dataset:&lt;BR /&gt;
&lt;BR /&gt;
School Month     StudentName      Subject    1Test  2Test  3Test  4Test  Total&lt;BR /&gt;
 ABC     July-10        John                Math         90     79        86    99       354  &lt;BR /&gt;
 ABC     July-10        John               Science      92     89        99    91     371     ABC     July-10        John               History       78     69        82    79       308&lt;BR /&gt;
 ABC     July-10        John               English       81     79        83    82       325&lt;BR /&gt;
 ABC     July-10       Becky              Math          92     77        76    88       333 &lt;BR /&gt;
 ABC     July-10       Becky              Science      67     76        65    83       291  ABC     July-10       Becky             History       78     69         76    79       302 ABC     July-10       Becky             English       90     79         80    81       330&lt;BR /&gt;
ABC     Dec-10        John                Math         97      93         89    99       378  &lt;BR /&gt;
ABC     Dec-10        John               Science      80      89         92    91       352&lt;BR /&gt;
ABC     Dec-10        John               History       70     77          76   80       303&lt;BR /&gt;
ABC     Dec-10        John               English       80     69        78    81       308 ABC     Dec-10       Becky              Math          80     70        67    82       299  ABC     Dec-10       Becky              Science     78      73        66    76       293&lt;BR /&gt;
 ABC     Dec-10       Becky             History       87     77         79    74      317&lt;BR /&gt;
 ABC     DEc-10       Becky             English      79     72         84    81      316&lt;BR /&gt;
&lt;BR /&gt;
I want the output dataset in the form :&lt;BR /&gt;
  &lt;BR /&gt;
Test1 	&lt;BR /&gt;
Math	July-10        Dec-10&lt;BR /&gt;
 John         90                    97&lt;BR /&gt;
Becky       92                    80&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I tried using proc tabulate, but could not get the desired form.&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
Blyzzard</description>
      <pubDate>Thu, 07 Apr 2011 04:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45947#M12165</guid>
      <dc:creator>excelsas</dc:creator>
      <dc:date>2011-04-07T04:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45948#M12166</link>
      <description>data one;&lt;BR /&gt;
	input School $ Month $ StudentName $ Subject $ Test1 Test2 Test3 Test4 Total;&lt;BR /&gt;
	datalines;&lt;BR /&gt;
ABC July-10 John Math 90 79 86 99 354 &lt;BR /&gt;
ABC July-10 John Science 92 89 99 91 371 &lt;BR /&gt;
ABC July-10 John History 78 69 82 79 308&lt;BR /&gt;
ABC July-10 John English 81 79 83 82 325&lt;BR /&gt;
ABC July-10 Becky Math 92 77 76 88 333 &lt;BR /&gt;
ABC July-10 Becky Science 67 76 65 83 291 &lt;BR /&gt;
ABC July-10 Becky History 78 69 76 79 302 &lt;BR /&gt;
ABC July-10 Becky English 90 79 80 81 330&lt;BR /&gt;
ABC Dec-10 John Math 97 93 89 99 378 &lt;BR /&gt;
ABC Dec-10 John Science 80 89 92 91 352&lt;BR /&gt;
ABC Dec-10 John History 70 77 76 80 303&lt;BR /&gt;
ABC Dec-10 John English 80 69 78 81 308 &lt;BR /&gt;
ABC Dec-10 Becky Math 80 70 67 82 299 &lt;BR /&gt;
ABC Dec-10 Becky Science 78 73 66 76 293&lt;BR /&gt;
ABC Dec-10 Becky History 87 77 79 74 317&lt;BR /&gt;
ABC Dec-10 Becky English 79 72 84 81 316&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=one; by subject studentname; run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=one out=two;&lt;BR /&gt;
	id month;&lt;BR /&gt;
	var test1 test2 test3 test4 total;&lt;BR /&gt;
	by subject studentname;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print; run;&lt;BR /&gt;
&lt;BR /&gt;
*partial output;&lt;BR /&gt;
&lt;BR /&gt;
 Subject     Name      _NAME_    July_10    Dec_10&lt;BR /&gt;
&lt;BR /&gt;
  Math       Becky    Test1        92         80&lt;BR /&gt;
  Math       John      Test1        90         97</description>
      <pubDate>Thu, 07 Apr 2011 13:10:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45948#M12166</guid>
      <dc:creator>NickR</dc:creator>
      <dc:date>2011-04-07T13:10:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45949#M12167</link>
      <description>Hello Excelsas,&lt;BR /&gt;
&lt;BR /&gt;
I do not know how to do it with proc TABULATE but it looks like this code does the trick (I've changed 1test to test1, 2test to test2 to comply with SAS naming requirements):&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc sort data=i;&lt;BR /&gt;
  by Subject StudentName;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=r1(drop=_name_) ;&lt;BR /&gt;
  var test1;&lt;BR /&gt;
  id month;&lt;BR /&gt;
  by Subject StudentName;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=r2(drop=_name_) ;&lt;BR /&gt;
  var test2;&lt;BR /&gt;
  id month;&lt;BR /&gt;
  by Subject StudentName;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=r3(drop=_name_) ;&lt;BR /&gt;
  var test3;&lt;BR /&gt;
  id month;&lt;BR /&gt;
  by Subject StudentName;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=i out=r4(drop=_name_) ;&lt;BR /&gt;
  var test4;&lt;BR /&gt;
  id month;&lt;BR /&gt;
  by Subject StudentName;&lt;BR /&gt;
run;&lt;BR /&gt;
data combine;&lt;BR /&gt;
  retain test;&lt;BR /&gt;
  set r1(in=r1) r2(in=r2) r3(in=r3) r4(in=r4);&lt;BR /&gt;
  if r1 then test="1test";&lt;BR /&gt;
  if r2 then test="2test";&lt;BR /&gt;
  if r3 then test="3test";&lt;BR /&gt;
  if r4 then test="4test";&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Sincerely,&lt;BR /&gt;
SPR</description>
      <pubDate>Thu, 07 Apr 2011 13:26:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45949#M12167</guid>
      <dc:creator>SPR</dc:creator>
      <dc:date>2011-04-07T13:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45950#M12168</link>
      <description>Can you try something like this?&lt;BR /&gt;
&lt;BR /&gt;
data one;&lt;BR /&gt;
input School $ Month $ StudentName $ Subject $ Test1 Test2 Test3 Test4 Total;&lt;BR /&gt;
datalines;&lt;BR /&gt;
ABC July-10 John Math 90 79 86 99 354 &lt;BR /&gt;
ABC July-10 John Science 92 89 99 91 371 &lt;BR /&gt;
ABC July-10 John History 78 69 82 79 308&lt;BR /&gt;
ABC July-10 John English 81 79 83 82 325&lt;BR /&gt;
ABC July-10 Becky Math 92 77 76 88 333 &lt;BR /&gt;
ABC July-10 Becky Science 67 76 65 83 291 &lt;BR /&gt;
ABC July-10 Becky History 78 69 76 79 302 &lt;BR /&gt;
ABC July-10 Becky English 90 79 80 81 330&lt;BR /&gt;
ABC Dec-10 John Math 97 93 89 99 378 &lt;BR /&gt;
ABC Dec-10 John Science 80 89 92 91 352&lt;BR /&gt;
ABC Dec-10 John History 70 77 76 80 303&lt;BR /&gt;
ABC Dec-10 John English 80 69 78 81 308 &lt;BR /&gt;
ABC Dec-10 Becky Math 80 70 67 82 299 &lt;BR /&gt;
ABC Dec-10 Becky Science 78 73 66 76 293&lt;BR /&gt;
ABC Dec-10 Becky History 87 77 79 74 317&lt;BR /&gt;
ABC Dec-10 Becky English 79 72 84 81 316&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc tabulate data=one;&lt;BR /&gt;
	class studentname subject month;&lt;BR /&gt;
	var test1;&lt;BR /&gt;
	table subject, studentname, month*test1;&lt;BR /&gt;
	keylabel sum=' ';&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
run;</description>
      <pubDate>Thu, 07 Apr 2011 18:01:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45950#M12168</guid>
      <dc:creator>AndyJ</dc:creator>
      <dc:date>2011-04-07T18:01:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45951#M12169</link>
      <description>Emmmm.Since you want dataset like that,It needs some more code,and process is much more complicated.&lt;BR /&gt;
See whether it is what you want;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data one;&lt;BR /&gt;
input School $ Month $ StudentName $ Subject $ Test1 Test2 Test3 Test4 Total;&lt;BR /&gt;
datalines;&lt;BR /&gt;
ABC July-10 John Math 90 79 86 99 354&lt;BR /&gt;
ABC July-10 John Science 92 89 99 91 371&lt;BR /&gt;
ABC July-10 John History 78 69 82 79 308&lt;BR /&gt;
ABC July-10 John English 81 79 83 82 325&lt;BR /&gt;
ABC July-10 Becky Math 92 77 76 88 333&lt;BR /&gt;
ABC July-10 Becky Science 67 76 65 83 291&lt;BR /&gt;
ABC July-10 Becky History 78 69 76 79 302&lt;BR /&gt;
ABC July-10 Becky English 90 79 80 81 330&lt;BR /&gt;
ABC Dec-10 John Math 97 93 89 99 378&lt;BR /&gt;
ABC Dec-10 John Science 80 89 92 91 352&lt;BR /&gt;
ABC Dec-10 John History 70 77 76 80 303&lt;BR /&gt;
ABC Dec-10 John English 80 69 78 81 308&lt;BR /&gt;
ABC Dec-10 Becky Math 80 70 67 82 299&lt;BR /&gt;
ABC Dec-10 Becky Science 78 73 66 76 293&lt;BR /&gt;
ABC Dec-10 Becky History 87 77 79 74 317&lt;BR /&gt;
ABC Dec-10 Becky English 79 72 84 81 316&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
 set one;&lt;BR /&gt;
 length _test $ 10;&lt;BR /&gt;
 array test{*} test: total;&lt;BR /&gt;
 do i=1 to dim(test);&lt;BR /&gt;
   _test=vname(test{i});&lt;BR /&gt;
   _value=test{i};&lt;BR /&gt;
   output;&lt;BR /&gt;
 end;&lt;BR /&gt;
 drop test: total i;&lt;BR /&gt;
run;&lt;BR /&gt;
proc sort data=temp;&lt;BR /&gt;
 by _test subject studentname;&lt;BR /&gt;
run;&lt;BR /&gt;
data op;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 by  _test subject studentname;&lt;BR /&gt;
 length _month  value $ 50;&lt;BR /&gt;
 retain _month value;&lt;BR /&gt;
 if first.studentname then call missing (_month ,value);&lt;BR /&gt;
 _month=catx(' ',_month,month);&lt;BR /&gt;
 value=catx(' ',value,_value);&lt;BR /&gt;
 if last.studentname then output;&lt;BR /&gt;
 drop _value month ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data want;&lt;BR /&gt;
 set op;&lt;BR /&gt;
 length row $ 50;&lt;BR /&gt;
 if _test ne lag(_test) then do;row=_test;output; end;&lt;BR /&gt;
 if subject ne lag(subject) then do;row=catx(' ',subject,_month); output; end;&lt;BR /&gt;
 row=catx(' ',studentname,value);output;&lt;BR /&gt;
 keep row;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp&lt;BR /&gt;
&lt;BR /&gt;
Message was edited by: Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Fri, 08 Apr 2011 04:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45951#M12169</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-04-08T04:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: how to change the format of dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45952#M12170</link>
      <description>Thanks a lot to all. It worked!!</description>
      <pubDate>Wed, 13 Apr 2011 03:31:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-change-the-format-of-dataset/m-p/45952#M12170</guid>
      <dc:creator>excelsas</dc:creator>
      <dc:date>2011-04-13T03:31:31Z</dc:date>
    </item>
  </channel>
</rss>

