<?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 in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590866#M18072</link>
    <description>&lt;P&gt;hello again.&lt;/P&gt;&lt;P&gt;I added the desired outcome in the attached file, which previously contained only the original format.&lt;/P&gt;&lt;P&gt;You can see the formula in excel that I computed to obtained the desired values.&lt;/P&gt;&lt;P&gt;Thank you very much for your attention.&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;</description>
    <pubDate>Mon, 23 Sep 2019 10:37:54 GMT</pubDate>
    <dc:creator>emaneman</dc:creator>
    <dc:date>2019-09-23T10:37:54Z</dc:date>
    <item>
      <title>Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/589250#M18030</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder whether you can help me with this issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In an experiment I have several groups of three participants each, with defined roles as D, M and O, answering questions about each other Subsequently, each participant evaluated the other two on variable Y, using a scale 0-100. The data looks like in the attached excel file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID= participant N&lt;/P&gt;&lt;P&gt;Group=group N&lt;/P&gt;&lt;P&gt;Role=Role (D, M o O)&lt;/P&gt;&lt;P&gt;V1me=self evaluation&amp;nbsp;&lt;/P&gt;&lt;P&gt;V1D=evaluation of the D within the group&lt;/P&gt;&lt;P&gt;V1M=evaluation of the M within the group&lt;/P&gt;&lt;P&gt;V1O=evaluation of the O within the group&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the participant has Role D, then V1D has missing value, since the participant did not evaluate the D, but evaluated the self, M and O. Same for the other Role(s).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to compute a measure of accuracy, by comparing the evaluation that one gives of the other two members within the group, to the evaluation that they give to themselves. For instance, if the participant is a D, then his/her D_accuracy missing, his M_accuracy it is the difference between his/her evaluation of M and the evaluation that M gives to himself/herself, and for O_accuracy is the difference between his/her evaluation of O and the evaluation that O gives to himself/herself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the data sample attached, the D accuracy for subject 1004 is missing value, for M it is 10 (10-0) and for O it is 0 (0-0).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like SAS to do this for me, so that three variables are ultimately added for each participants, indicating D_accuracy, M_accuracy and O-accuracy.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestion would be welcome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;E&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="0" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ID&lt;/TD&gt;&lt;TD&gt;group&lt;/TD&gt;&lt;TD&gt;Role&lt;/TD&gt;&lt;TD&gt;V1me&lt;/TD&gt;&lt;TD&gt;V1D&lt;/TD&gt;&lt;TD&gt;V1M&lt;/TD&gt;&lt;TD&gt;V1O&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Group&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 05:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/589250#M18030</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2019-09-17T05:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/589927#M18043</link>
      <description>can you show what the source data would look like?</description>
      <pubDate>Thu, 19 Sep 2019 06:27:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/589927#M18043</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-19T06:27:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590030#M18052</link>
      <description>&lt;P&gt;Hello&amp;nbsp;VinitvictorCorr,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;The source data file should be attached to the original posting of mine, but I include it here, too.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;This source data is only a sample of the entire file, with two groups (variable "group"of three people each.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;Thanks for considering to look into it!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;E&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2019 14:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590030#M18052</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2019-09-19T14:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590815#M18069</link>
      <description>OK,, i thought of it as a result.. so you want the results of v1d,v1m,v1o to be in one column ? if it is else-wise, could you please show me how the end result would look like? I don't want to provide you with a wrong code.</description>
      <pubDate>Mon, 23 Sep 2019 03:51:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590815#M18069</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-23T03:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590866#M18072</link>
      <description>&lt;P&gt;hello again.&lt;/P&gt;&lt;P&gt;I added the desired outcome in the attached file, which previously contained only the original format.&lt;/P&gt;&lt;P&gt;You can see the formula in excel that I computed to obtained the desired values.&lt;/P&gt;&lt;P&gt;Thank you very much for your attention.&lt;/P&gt;&lt;P&gt;E&lt;/P&gt;</description>
      <pubDate>Mon, 23 Sep 2019 10:37:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/590866#M18072</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2019-09-23T10:37:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591079#M18083</link>
      <description>&lt;P&gt;Heres your program. Its a little big and not alligned well :p, but it should do the trick:-&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA WORK.trial1;&lt;BR /&gt;LENGTH&lt;BR /&gt;ID 8&lt;BR /&gt;Group 8&lt;BR /&gt;Role $ 1&lt;BR /&gt;V1me 8&lt;BR /&gt;V1D 8&lt;BR /&gt;V1M 8&lt;BR /&gt;V1O 8 ;&lt;BR /&gt;FORMAT&lt;BR /&gt;ID BEST12.&lt;BR /&gt;Group BEST12.&lt;BR /&gt;Role $CHAR1.&lt;BR /&gt;V1me BEST12.&lt;BR /&gt;V1D BEST12.&lt;BR /&gt;V1M BEST12.&lt;BR /&gt;V1O BEST12. ;&lt;BR /&gt;INFORMAT&lt;BR /&gt;ID BEST12.&lt;BR /&gt;Group BEST12.&lt;BR /&gt;Role $CHAR1.&lt;BR /&gt;V1me BEST12.&lt;BR /&gt;V1D BEST12.&lt;BR /&gt;V1M BEST12.&lt;BR /&gt;V1O BEST12. ;&lt;BR /&gt;INFILE "please put your path\filename here"'&lt;BR /&gt;LRECL=18&lt;BR /&gt;ENCODING="WLATIN1"&lt;BR /&gt;TERMSTR=CRLF&lt;BR /&gt;DLM='7F'x&lt;/P&gt;
&lt;P&gt;MISSOVER&lt;BR /&gt;DSD ;&lt;BR /&gt;INPUT&lt;BR /&gt;ID : BEST32.&lt;BR /&gt;Group : BEST32.&lt;BR /&gt;Role : $CHAR1.&lt;BR /&gt;V1me : BEST32.&lt;BR /&gt;V1D : BEST32.&lt;BR /&gt;V1M : BEST32.&lt;BR /&gt;V1O : BEST32. ;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;DATA K/*(KEEP=ID GROUP ROLE V1ME)*/;&lt;BR /&gt;SET TRIAL1;&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select id,count(id) into :idvars separated by " _num_",:cnt from k;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;PROC SORT DATA=K(rename=(v1d=d v1m=m v1o=o));BY id;RUN;&lt;/P&gt;
&lt;P&gt;PROC TRANSPOSE DATA=K OUT=L name=role prefix=_num_;&lt;BR /&gt;BY group;&lt;BR /&gt;ID id;&lt;BR /&gt;VAR d m o;&lt;BR /&gt;RUN;&lt;BR /&gt;data l;&lt;BR /&gt;set l;&lt;BR /&gt;role=upcase(role);&lt;/P&gt;
&lt;P&gt;data c(keep=role v1me);&lt;BR /&gt;set k;&lt;BR /&gt;run;&lt;BR /&gt;proc sort data=c;by role;&lt;BR /&gt;proc sort data=l;by role;&lt;BR /&gt;data s;&lt;BR /&gt;merge l(in=a) c;&lt;BR /&gt;by role;&lt;BR /&gt;if a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%macro count;&lt;/P&gt;
&lt;P&gt;%do i=1 %to &amp;amp;cnt.;&lt;BR /&gt;data s;&lt;BR /&gt;set s;&lt;BR /&gt;%scan(_num_&amp;amp;idvars.,&amp;amp;i.)=%scan(_num_&amp;amp;idvars.,&amp;amp;i.)-v1me;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;/P&gt;
&lt;P&gt;%mend count;&lt;BR /&gt;%count;&lt;/P&gt;
&lt;P&gt;Proc sort data=s;by group ;&lt;/P&gt;
&lt;P&gt;proc transpose data=s out=a name=ida;&lt;BR /&gt;by group ;&lt;BR /&gt;id role;&lt;BR /&gt;var _num_&amp;amp;idvars.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;data b(drop=ida);&lt;BR /&gt;set a;&lt;BR /&gt;id=input(compress(ida,"_num_"),best.);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;proc sort data=k out=met(keep=id group);by id group;&lt;BR /&gt;proc sort data=b;by id group;&lt;/P&gt;
&lt;P&gt;data t(rename=(D=D_accuracy M=M_Accuracy O=O_Accuracy));&lt;BR /&gt;merge met(in=a) b;&lt;BR /&gt;by id group;&lt;BR /&gt;if a;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the input dataset is trial1 and output dataset is t.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note:- please change the location in the infile statement. Also let me know if you need any changes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The output looks like below attached screenshot&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2019 05:49:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591079#M18083</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-24T05:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591431#M18091</link>
      <description>&lt;P&gt;Hello again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all this effort and code! I am having only one issue with the&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;INFILE. I substitute with the path to the CSV file, but it doesn't like that.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;e&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 09:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591431#M18091</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2019-09-25T09:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591438#M18092</link>
      <description>if you are using sas, direct import it using import tab in file and dont use the first part of the code&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Sep 2019 09:09:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591438#M18092</guid>
      <dc:creator>VinitvictorCorr</dc:creator>
      <dc:date>2019-09-25T09:09:38Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Transpose</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591729#M18095</link>
      <description>&lt;P&gt;thank you, i will try that.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Sep 2019 23:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Proc-Transpose/m-p/591729#M18095</guid>
      <dc:creator>emaneman</dc:creator>
      <dc:date>2019-09-25T23:22:59Z</dc:date>
    </item>
  </channel>
</rss>

