<?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: Can I Transpose only 1 variable out of Many in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323112#M71572</link>
    <description>&lt;P&gt;Could you use the 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; to create that data as a data step that you could paste here as text? Then we would have a data set we could test code against.&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;And what value would Body_head, body_neck,&amp;nbsp; have?&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2017 22:32:04 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2017-01-06T22:32:04Z</dc:date>
    <item>
      <title>Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322880#M71488</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset with 24 variables, but I would only like to transpose 3 of them while keeping the others in the same orientation. &amp;nbsp;The dataset describes a physical exam by body part and whether the exam is normal/abnormal and if abnormal the diagnosis is indicated. &amp;nbsp;The datasets looks as follows:&lt;/P&gt;&lt;P&gt;TrialID Center Patient Visit ExamDt Body Exam Diag Sex Race Consent ConsentDt Wt RandomDt PerformStat Trt StopReas TrtGive Age TrtDt CtrPt TrialCtrPt&lt;/P&gt;&lt;P&gt;Body has the following categories: head, eye, ear, nose, throat, neck, lymph node, breast, heart, abdomen, lung/thorax, genitourinary, extremities, musculoskeletal, skin, neurologic, additional&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each patient has an enty for each body part so there are numerous rows with the same patient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to only transpose body, exam and diag while keeping the other variables in the same orientation? &amp;nbsp; &amp;nbsp;I have tried, but it seems that only the variable in the code below and the other variables will be dropped in the transposed dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose data=medhistory out=transmedhist(drop=_:) prefix=exam_;&lt;BR /&gt;var exam;&lt;BR /&gt;by &lt;SPAN&gt;TrialCtrPt&lt;/SPAN&gt;;&lt;BR /&gt;id body;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 02:20:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322880#M71488</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-06T02:20:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322886#M71489</link>
      <description>&lt;P&gt;If I've interpreted what you want correctly, this will come close. I'm assuming that you want multiple body category examinations and diagnoses per patient. I'm also assuming that&amp;nbsp;&lt;EM&gt;trialctrpt&lt;/EM&gt; is the patient id, and&amp;nbsp;&lt;EM&gt;patient&lt;/EM&gt; is some other way of identifying them. Don't worry too much about the first three steps - it's just my attempt at mocking up some test data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Rather than trying to do it all in one&amp;nbsp;&lt;EM&gt;transpose&lt;/EM&gt;, which then requires lots of complicated arrays and post-processing, I went over the patient/body/exam/diag data three times, and then rejoined back with the original dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data medhistory(drop=body exam diag)
     patient(keep=trialctrpt body exam diag);
length TrialID Center Patient Visit ExamDt 8;
length Body exam diag $ 20;
length Sex Race Consent ConsentDt Wt RandomDt PerformStat Trt StopReas TrtGive Age TrtDt CtrPt TrialCtrPt 8;
array body_a[17] $ 20 _temporary_ ('head', 'eye', 'ear', 'nose', 'throat', 'neck', 'lymph node', 'breast', 'heart', 'abdomen', 
                            'lung/thorax', 'genitourinary', 'extremities', 'musculoskeletal', 'skin', 'neurologic',
                            'additional');
call missing(of _all_);
do trialctrpt = 1 to 100;
   do i = 1 to int(ranuni(225465114) * 3) + 1;
      body = body_a[int(ranuni(225465114) * dim(body_a)) + 1];
      exam = ifc(ranuni(225465114) &amp;gt; .1, 'normal', 'abnormal');
      diag = ifc(exam = 'abnormal', 'indicated', ' ');
      output patient;    /* Multiple observations per patient (in this example, up to 3) */
      end;
   output medhistory;    /* Single observations per patient */
   end;
stop;
keep TrialID Center Patient Visit ExamDt Body exam diag 
     sex Race Consent ConsentDt Wt RandomDt PerformStat Trt StopReas TrtGive Age TrtDt CtrPt TrialCtrPt ;
run;

/*
    Clean data to stop multiple body entries per patient 
*/
proc sort data=patient noequals;
by trialctrpt body exam;
run;

data patient;
set patient;
by trialctrpt body;
if first.body;
run;

/*
   Get the three different transpositions
*/
proc transpose data=patient out=transbody(drop=_name_) prefix=body_;
by trialctrpt;
var body;
run;

proc transpose data=patient out=transexam(drop=_name_) prefix=exam_;
by trialctrpt;
var exam;
run;

proc transpose data=patient out=transdiag(drop=_name_) prefix=diag_;
by trialctrpt;
var diag;
run; 
  
/*
    Join back with the patient records.
*/
data medhistory;
set medhistory;
set transbody;
set transexam;
set transdiag;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jan 2017 03:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322886#M71489</guid>
      <dc:creator>LaurieF</dc:creator>
      <dc:date>2017-01-06T03:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322895#M71494</link>
      <description>&lt;P&gt;Are you going from a long to wide - adding/creating variables for final data set?&lt;/P&gt;
&lt;P&gt;Or wide to long - reducing the number of variables?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 04:53:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/322895#M71494</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-01-06T04:53:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323044#M71539</link>
      <description>&lt;P&gt;It really helps to clarify problems with a few rows of example input or starting data and the desired result for that output.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 17:02:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323044#M71539</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-06T17:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323071#M71555</link>
      <description>It is currently in the long format, but I only want to convert three of the variables to the wide format. I do not want to convert all the variables to the wide format since I need the long format for analysis. Thanks.</description>
      <pubDate>Fri, 06 Jan 2017 19:20:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323071#M71555</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-06T19:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323074#M71557</link>
      <description>&lt;P&gt;Sorry about that. &amp;nbsp;An example of the dataset is:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TrialID &lt;/SPAN&gt;&lt;SPAN&gt;Center Patient Visit ExamDt &amp;nbsp; &amp;nbsp; &amp;nbsp; Body &amp;nbsp; &amp;nbsp; &amp;nbsp;Exam &amp;nbsp; &amp;nbsp;Diag &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Sex Race Consent ConsentDt &amp;nbsp; &amp;nbsp;Wt&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp; head &amp;nbsp; &amp;nbsp;normal &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;F &amp;nbsp; &amp;nbsp; W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes &amp;nbsp; &amp;nbsp; &amp;nbsp;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp;115&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp; neck&amp;nbsp; &amp;nbsp; normal &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F &amp;nbsp; &amp;nbsp; W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes &amp;nbsp; &amp;nbsp; &amp;nbsp;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp;115&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp; heart&amp;nbsp; &amp;nbsp;abnormal &amp;nbsp; htn &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F &amp;nbsp; &amp;nbsp; W &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes &amp;nbsp; &amp;nbsp; &amp;nbsp;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp;115&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;abc &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1 &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;SPAN&gt;2/3/1990 &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;heart&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;ab&lt;/SPAN&gt;&lt;SPAN&gt;normal &amp;nbsp; htn &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; F &amp;nbsp; &amp;nbsp; B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes &amp;nbsp; &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp;110&lt;/SPAN&gt;&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;&lt;SPAN&gt;RandomDt PerformStat Trt StopReas TrtGive Age TrtDt &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CtrPt &amp;nbsp; &amp;nbsp; TrialCtrPt&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x &amp;nbsp; &amp;nbsp; PD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25 &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp;1/1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc/1/1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x &amp;nbsp; &amp;nbsp; PD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25 &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp;1/1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc/1/1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2/1/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x &amp;nbsp; &amp;nbsp; PD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 25 &amp;nbsp; &amp;nbsp;2/3/1990 &amp;nbsp; &amp;nbsp;1/1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc/1/1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2/3/1990 &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;x &amp;nbsp; &amp;nbsp; PD &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; x &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 30&amp;nbsp; &amp;nbsp; 2/3/1990 &amp;nbsp; &amp;nbsp;2/1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;abc/2/1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would like the data to be the same for all the variables except body, exam and diag which I would think would be column headings of exam_head, exam_neck, etc and the same for diag (diag_head, diag_neck, etc.).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Hopefully that helps clarify what I am looking for.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 19:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323074#M71557</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-06T19:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323112#M71572</link>
      <description>&lt;P&gt;Could you use the 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; to create that data as a data step that you could paste here as text? Then we would have a data set we could test code against.&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;And what value would Body_head, body_neck,&amp;nbsp; have?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:32:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323112#M71572</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-06T22:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323116#M71574</link>
      <description>&lt;P&gt;Here is a stab at what I think you may be asking for minus what ever would go into Body_ etc variables.&lt;/P&gt;
&lt;P&gt;Note I am only using part of your example data as 1) I didn't want to spend too much time getting a workable data&amp;nbsp; set, 2) adding the other variables is just adding to them to the select statement in the proc sql&lt;/P&gt;
&lt;P&gt;The BY statements all need to have the same variables, in the same order and should be the minimum needed to identify the specific bit you want.&lt;/P&gt;
&lt;PRE&gt;data have;
   informat TrialID $5.  ExamDt mmddyy10.  Body $10.     Exam $10.   Diag $10.    Sex $1. Race $1. Consent $5. ConsentDt mmddyy10.  ;
   format examdt consentdt mmddyy10.;
   input TrialID Center Patient Visit ExamDt       Body      Exam    Diag          Sex Race Consent ConsentDt    Wt ;
datalines;
abc           1       1        1      2/3/1990     head    normal      .                F     W        Yes      2/1/1990      115
abc           1       1        1      2/3/1990     neck    normal      .                 F     W        Yes      2/1/1990      115
abc           1       1        1      2/3/1990     heart   abnormal   htn           F     W        Yes      2/1/1990      115
abc           2       1        1      2/3/1990     heart   abnormal   htn           F     B       Yes      2/3/1990      110
;
run;

proc sort data=have;
  by TrialID Center Patient Visit ExamDt;
run;

proc transpose data=have (drop=diag) out=transexam (drop=_name_)
   prefix=exam_;
   by TrialID Center Patient Visit ExamDt;
   var exam;
   id body;
run;
proc transpose data=have (drop=exam) out=transdiag (drop=_name_)
   prefix=diag_;
   by TrialID Center Patient Visit ExamDt;
   var diag;
   id body;
run;
proc sql;
   create table temp as
   select distinct TrialID,Center,Patient,Visit,ExamDt,Sex,Race,Consent,ConsentDt,Wt
   from have
   order  by TrialID,Center,Patient,Visit,ExamDt;
quit;

data want;
   merge temp transexam transdiag;
   by TrialID Center Patient Visit ExamDt;
run;

&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Jan 2017 22:42:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323116#M71574</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-06T22:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323437#M71687</link>
      <description>There would not be a body_head. It would be exam_head and diag_head. The entries under body are head, eye, ear, nose, throat, etc. I will include my code in a separate reply</description>
      <pubDate>Mon, 09 Jan 2017 18:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323437#M71687</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-09T18:48:36Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323470#M71700</link>
      <description>&lt;P&gt;Please find the code below to generate the data&lt;/P&gt;&lt;P&gt;data mock;&lt;BR /&gt;infile datalines dsd;&lt;BR /&gt;input trialid $ centre pt visit examdt mmddyy. body&amp;nbsp;$ exam $ diag $ sex $ race $ consent $ consentdt mmddyy. wt randomdt mmddyy. performstat trt $ stopreas $ trtgive $ age&lt;BR /&gt;trtdt mmddyy. ctrpt $ trialctrpt $ ;&lt;BR /&gt;datalines;&lt;BR /&gt;abc,1,1,2/3/1990,head,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,eye,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,ear,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,nose,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,throat,abnormal,lump,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,neck,abnormal,enlarged,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,lymphnode,abnormal,large,,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,breast,abnormal,warm,,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,heart,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,abdomen,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,lung/thorax,abnormal,dyspnea,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,genitourinary,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,extremities,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,musculoskeletal,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,skin,abnormal,discolored,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,1,1,2/3/1990,neurologic,normal, ,F,W,Yes,2/1/1990,115,2/1/1990,1,x,PD,x,25,2/3/1990,1/1,abc/1/1&lt;BR /&gt;abc,2,1,2/3/1990,head,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,eye,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,ear,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,nose,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,throat,abnormal,lump,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,neck,abnormal,enlarged,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,lymphnode,abnormal,large,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,breast,abnormal,warm,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,heart,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,abdomen,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,lung/thorax,abnormal,dyspnea,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,genitourinary,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,extremities,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,musculoskeletal,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,skin,abnormal,discolored,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,2,1,2/3/1990,neurologic,normal, ,F,B,Yes,2/3/1990,110,2/3/1990,1,x,PD,x,30,2/3/1990,2/1,abc/2/1&lt;BR /&gt;abc,3,1,2/3/1990,head,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,eye,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,ear,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,nose,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,throat,abnormal,lump,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,neck,abnormal,enlarged,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,lymphnode,abnormal,large,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,breast,abnormal,warm,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,heart,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,abdomen,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,lung/thorax,abnormal,dyspnea,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,genitourinary,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,extremities,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,musculoskeletal,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,skin,abnormal,discolored, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,3,1,2/3/1990,neurologic,normal, ,M,W,Yes,2/3/1990,140,2/3/1990,1,x,death,x,30,2/3/1990,3/1,abc/3/1&lt;BR /&gt;abc,4,1,2/3/1990,head,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,eye,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,ear,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,nose,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,throat,abnormal,lump,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,neck,abnormal,enlarged,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,lymphnode,abnormal,large,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,breast,abnormal,warm,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,heart,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,abdomen,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,lung/thorax,abnormal,dyspnea,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,genitourinary,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,extremities,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,musculoskeletal,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,skin,abnormal,discolored,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;BR /&gt;abc,4,1,2/3/1990,neurologic,normal, ,M,B,Yes,2/3/1990,165,2/3/1990,1,x,death,x,45,2/3/1990,4/1,abc/4/1&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 22:42:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323470#M71700</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-09T22:42:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323489#M71715</link>
      <description>&lt;P&gt;Does that code correctly run for you when you copy and paste into an editor and run?&lt;/P&gt;
&lt;P&gt;I get multple blocks similar to:&lt;/P&gt;
&lt;PRE&gt;NOTE: Invalid data for visit in line 14 9-16.
NOTE: Invalid data for examdt in line 14 18-23.
NOTE: Invalid data for consentdt in line 14 49-54.
NOTE: Invalid data for wt in line 14 55-60.
NOTE: Invalid data for randomdt in line 14 62-67.
NOTE: Invalid data for age in line 14 83-85.
NOTE: Invalid data for trtdt in line 14 87-92.
&lt;/PRE&gt;
&lt;P&gt;Your examdt is the 5th variable on the input statement but the values are the 4th. So the exam date is being read into visit (unsuccessfully in general).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 00:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323489#M71715</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-10T00:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: Can I Transpose only 1 variable out of Many in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323688#M71776</link>
      <description>My apologies again. It did run, but I added I few more variables to make it closer to my actual dataset and now I can't seem to get it to run properly. I fixed the number of variables from what I can tell. Sorry about that. I am not very experienced at creating mock data and complicated mock data at that.</description>
      <pubDate>Tue, 10 Jan 2017 15:57:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-I-Transpose-only-1-variable-out-of-Many-in-a-dataset/m-p/323688#M71776</guid>
      <dc:creator>PaulaC</dc:creator>
      <dc:date>2017-01-10T15:57:46Z</dc:date>
    </item>
  </channel>
</rss>

