<?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: proc transpose nightmare in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31016#M7379</link>
    <description>If the original goal is to find out BY case number what the unique test values are, then a combo of the NLEVELS option and a BY statement in PROC FREQ may get what she wants. De-duping the original data set might still be a good idea, but, for example:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=sashelp.prdsale nlevels;&lt;BR /&gt;
  by country;&lt;BR /&gt;
  table division;&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
If the -original- input data showed one case/test per obs, then the above technique would show the unique test values for each case.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
options nodate nonumber nocenter;&lt;BR /&gt;
                      &lt;BR /&gt;
data testcase;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input date : mmddyy10. casenum testtype result $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
11/15/2008 1 4545 redo&lt;BR /&gt;
11/16/2008 1 4545 OK&lt;BR /&gt;
11/16/2008 1 4400 pass&lt;BR /&gt;
11/17/2008 1 4433 redo&lt;BR /&gt;
11/18/2008 1 5454 OK&lt;BR /&gt;
12/15/2008 2 4322 redo&lt;BR /&gt;
12/16/2008 2 4322 OK&lt;BR /&gt;
12/16/2008 2 2432 pass&lt;BR /&gt;
12/17/2008 2 5555 OK&lt;BR /&gt;
10/15/2008 3 3333 redo&lt;BR /&gt;
10/16/2008 3 6543 OK&lt;BR /&gt;
10/16/2008 3 4545 pass&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=testcase nlevels;&lt;BR /&gt;
  by casenum;&lt;BR /&gt;
  table testtype;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
    <pubDate>Wed, 13 May 2009 14:33:21 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2009-05-13T14:33:21Z</dc:date>
    <item>
      <title>proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31013#M7376</link>
      <description>Hi, I transposed every variable in my dataset which is mostly efficient; I have the correct number of observations now; however, I'm having a problem sorting out one set of variables.&lt;BR /&gt;
Let's call them TEST. I have TEST1-TEST11 for every subject.&lt;BR /&gt;
&lt;BR /&gt;
Here's an example:&lt;BR /&gt;
&lt;BR /&gt;
CASE#1 TEST1 4545 TEST2 4545 TEST3 4400 TEST4 4433 TEST 5.....&lt;BR /&gt;
CASE#2 TEST1 4322 TEST2 4322 TEST3 2432 TEST4 5555&lt;BR /&gt;
CASE#3 TEST1 3333 TEST2 3333 TEST3 3333 TEST4 6543&lt;BR /&gt;
&lt;BR /&gt;
As you can see, I have a problem, because for some reason I have all those repetitions.&lt;BR /&gt;
I want to figure out a way in which I can count, for each individual subject in the study, which tests were done. I don't care about the random ordering of test1-test11; I just care about the test result NUMBERS.&lt;BR /&gt;
&lt;BR /&gt;
I'd like to be able to say for CASE#1 that I have 4545, 4400 and 4433.&lt;BR /&gt;
And for CASE#2 that the results were 4322, 2432 and 5555&lt;BR /&gt;
And for CASE#3 that the results were 3333 and 6543.&lt;BR /&gt;
&lt;BR /&gt;
In other words, I only want to know if the test result show up at all, and what it is.&lt;BR /&gt;
Is there some sort of loop that I can do? Will I have to reverse-transpose (but then I am pretty much back where I started...)? &lt;BR /&gt;
&lt;BR /&gt;
ANY HELP WOULD BE SO MUCH APPRECIATED &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;
I am stuck.</description>
      <pubDate>Tue, 12 May 2009 22:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31013#M7376</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-12T22:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31014#M7377</link>
      <description>Can you share your proc transpose code and some rows of the original dataset. Under normal cirumstances proc transpose does not create duplicates.</description>
      <pubDate>Wed, 13 May 2009 06:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31014#M7377</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2009-05-13T06:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31015#M7378</link>
      <description>If you don't care to transpose duplicate values, then sort your input file using NODUPKEY to remove duplicate NUMBERS instances for a given BY variable list.  Then transpose your de-dup'd output file so that you only get one unique value.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 13 May 2009 13:26:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31015#M7378</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-05-13T13:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31016#M7379</link>
      <description>If the original goal is to find out BY case number what the unique test values are, then a combo of the NLEVELS option and a BY statement in PROC FREQ may get what she wants. De-duping the original data set might still be a good idea, but, for example:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=sashelp.prdsale nlevels;&lt;BR /&gt;
  by country;&lt;BR /&gt;
  table division;&lt;BR /&gt;
run;&lt;BR /&gt;
               &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
If the -original- input data showed one case/test per obs, then the above technique would show the unique test values for each case.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
options nodate nonumber nocenter;&lt;BR /&gt;
                      &lt;BR /&gt;
data testcase;&lt;BR /&gt;
  infile datalines;&lt;BR /&gt;
  input date : mmddyy10. casenum testtype result $;&lt;BR /&gt;
return;&lt;BR /&gt;
datalines;&lt;BR /&gt;
11/15/2008 1 4545 redo&lt;BR /&gt;
11/16/2008 1 4545 OK&lt;BR /&gt;
11/16/2008 1 4400 pass&lt;BR /&gt;
11/17/2008 1 4433 redo&lt;BR /&gt;
11/18/2008 1 5454 OK&lt;BR /&gt;
12/15/2008 2 4322 redo&lt;BR /&gt;
12/16/2008 2 4322 OK&lt;BR /&gt;
12/16/2008 2 2432 pass&lt;BR /&gt;
12/17/2008 2 5555 OK&lt;BR /&gt;
10/15/2008 3 3333 redo&lt;BR /&gt;
10/16/2008 3 6543 OK&lt;BR /&gt;
10/16/2008 3 4545 pass&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
                  &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=testcase nlevels;&lt;BR /&gt;
  by casenum;&lt;BR /&gt;
  table testtype;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 13 May 2009 14:33:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31016#M7379</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-05-13T14:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31017#M7380</link>
      <description>I'm sorry Cynthia, I didn't understand what you meant in you last message.&lt;BR /&gt;
I am not doing anything involving datalines, just using data and set statements;&lt;BR /&gt;
&lt;BR /&gt;
I now have a unique BY variable for each case, and I want to pull out tests per case (only if they are different)....&lt;BR /&gt;
&lt;BR /&gt;
The duplicates are there because there are multiple times that the test has been recorded; however, I just want to pull out the unique tests done per case.&lt;BR /&gt;
&lt;BR /&gt;
I am such a novice I don't even understand that last code. Thanks &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Tue, 19 May 2009 14:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31017#M7380</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-05-19T14:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31018#M7381</link>
      <description>Hi:&lt;BR /&gt;
  No need to apologize...I was sending you code that you could run to see the results. The "datalines" is a way to read data into SAS -- so in my case, it was a way to take some lines of data, read them into SAS. This has the benefit that you can -see- what the input data looks like as it is turned into a SAS dataset.&lt;BR /&gt;
 &lt;BR /&gt;
  The relevant code in that example was the PROC FREQ:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=testcase nlevels;&lt;BR /&gt;
  by casenum;&lt;BR /&gt;
  tables testtype;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
          &lt;BR /&gt;
PROC FREQ does counts and percents of counts in a very handy way and creates a report in the LISTING window (if you do not use the Output Delivery System). &lt;BR /&gt;
&lt;BR /&gt;
If you need a TABLE in order to do further analysis, then you might need to use some other procedure or processing. It really depends on the end result that you want/need -- do you just need a report? What do you mean by "pull out tests per case"? Do you need these observations "only if they are different" to go into another analysis or do you just need a report on the tests that are different for each case.&lt;BR /&gt;
&lt;BR /&gt;
For example, if you want to rid your dataset of duplicates, then you can look at the PROC SORT procedure, which has several different options for deleting duplicate procedures. If you need to remove duplicates based on some logical condition -- theoretically, you need to remove every duplicate test, but not if it occured on Friday -- that would involve a DATA step because PROC SORT could not handle the logical test.&lt;BR /&gt;
&lt;BR /&gt;
Frequently, when you use SAS, in order to get from Point A to Point B, you might have to run several different procedure or data steps to get your data cleaned up and in the right shape for the analytical procedure you plan to use.&lt;BR /&gt;
 &lt;BR /&gt;
Sorry I was unclear in my post. I hope this helps.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 19 May 2009 16:33:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31018#M7381</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-05-19T16:33:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose nightmare</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31019#M7382</link>
      <description>Hi:&lt;BR /&gt;
  No need to apologize...I was sending you code that you could run to see the results. The "datalines" is a way to read data into SAS -- so in my case, it was a way to take some lines of data, read them into SAS. This has the benefit that you can -see- what the input data looks like as it is turned into a SAS dataset.&lt;BR /&gt;
 &lt;BR /&gt;
  The relevant code in that example was the PROC FREQ:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc freq data=testcase nlevels;&lt;BR /&gt;
  by casenum;&lt;BR /&gt;
  tables testtype;&lt;BR /&gt;
run;&lt;BR /&gt;
                 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
          &lt;BR /&gt;
PROC FREQ does counts and percents of counts in a very handy way and creates a report in the LISTING window (if you do not use the Output Delivery System). &lt;BR /&gt;
&lt;BR /&gt;
If you need a TABLE in order to do further analysis, then you might need to use some other procedure or processing. It really depends on the end result that you want/need -- do you just need a report? What do you mean by "pull out tests per case"? Do you need these observations "only if they are different" to go into another analysis or do you just need a report on the tests that are different for each case.&lt;BR /&gt;
&lt;BR /&gt;
For example, if you want to rid your dataset of duplicates, then you can look at the PROC SORT procedure, which has several different options for deleting duplicate procedures. If you need to remove duplicates based on some logical condition -- theoretically, you need to remove every duplicate test, but not if it occured on Friday -- that would involve a DATA step because PROC SORT could not handle the logical test.&lt;BR /&gt;
&lt;BR /&gt;
Frequently, when you use SAS, in order to get from Point A to Point B, you might have to run several different procedure or data steps to get your data cleaned up and in the right shape for the analytical procedure you plan to use.&lt;BR /&gt;
 &lt;BR /&gt;
Sorry I was unclear in my post. I hope this helps.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 19 May 2009 16:33:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-transpose-nightmare/m-p/31019#M7382</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-05-19T16:33:54Z</dc:date>
    </item>
  </channel>
</rss>

