<?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: Combining five datasets in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411874#M3944</link>
    <description>&lt;P&gt;Merge is not the method to use for this. This can be done very simply by:&lt;/P&gt;
&lt;PRE&gt;/* Step 1 - set all data together, and put year in as a data item */
data inter;
  set hyptabs.src_utah_vitals: indsname=tmp;
  year=scan(tmp,4,"_");
run;

/* Transpose the data */
proc transpose data=inter out=want;
  by year;
  var value;
  idlabel measure;
run;&lt;/PRE&gt;
&lt;P&gt;This shows a couple of things:&lt;BR /&gt;1) Why putting data into dataset names/variables is not a good idea.&amp;nbsp; If you keep data in the body of the table you can use it, manipulate it etc.&amp;nbsp; From a programmer point of view, data in names is really bad as it makes all programming far more difficult.&lt;/P&gt;
&lt;P&gt;2) Using : means all items with a prefix of&lt;/P&gt;
&lt;P&gt;3) Transpose procedure - this is designed to move data from long to wide or from wide to long.&amp;nbsp; Unless your data has multiple variables, it is the ideal solution for this (for multiple variables array approach is ideal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Nov 2017 11:26:55 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2017-11-09T11:26:55Z</dc:date>
    <item>
      <title>Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411799#M3933</link>
      <description>&lt;P&gt;I am combining&amp;nbsp;five datasets:&amp;nbsp;&lt;/P&gt;&lt;P&gt;HypTabs.Src_Utah_Vitals_2010&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2011&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2012&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2013&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2014&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All the datasets&amp;nbsp;have variables in this format:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-11-08 at 20.34.34.png" style="width: 293px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16540i687E3EF0489F9EC3/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-11-08 at 20.34.34.png" alt="Screen Shot 2017-11-08 at 20.34.34.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create the four variables HtIn, WtLb, SBP, DBP from this data set. In other words I need to for example combine all the systolic BP into one column.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess I have no idea even how to get started with combining all the variables this way. Any ideas?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 03:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411799#M3933</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T03:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411803#M3934</link>
      <description>&lt;P&gt;PROC TRANSPOSE.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 03:44:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411803#M3934</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T03:44:30Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411806#M3936</link>
      <description>&lt;P&gt;Is it possible to do it with a MERGE statement? We just haven't learned about PROC TRANSPOSE in class yet, so I think we are expected to use MERGE, but I'm not super good at it yet.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 03:52:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411806#M3936</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T03:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411809#M3938</link>
      <description>&lt;P&gt;Not easily....you somehow have to reformat your data first. You could split it multiple times and merge but that seems silly when there's a proc that will do it in one step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It may be I'm not interpreting your question properly though. I assume you want something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Year Height Weight BP_Systolic BP_Diastolic&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2010&lt;/P&gt;
&lt;P&gt;2011&lt;/P&gt;
&lt;P&gt;2012&lt;/P&gt;
&lt;P&gt;2013&lt;/P&gt;
&lt;P&gt;2010&lt;/P&gt;
&lt;P&gt;....&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 03:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411809#M3938</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T03:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411810#M3939</link>
      <description>This is the other way to 'transpose' without using PROC TRANSPOSE, if you've been learning arrays maybe this works for you: &lt;A href="https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/modules/reshaping-data-long-to-wide-using-the-data-step/&lt;/A&gt;</description>
      <pubDate>Thu, 09 Nov 2017 03:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411810#M3939</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T03:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411812#M3940</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-11-08 at 20.58.27.png" style="width: 504px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16541i942B4D07BD3C97B6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-11-08 at 20.58.27.png" alt="Screen Shot 2017-11-08 at 20.58.27.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This it the format I ultimately want to end up with. We have learned arrays, so that could be an option. I just remember hearing something about using MERGE, so I think that's why I thought of that.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 04:00:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411812#M3940</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T04:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411874#M3944</link>
      <description>&lt;P&gt;Merge is not the method to use for this. This can be done very simply by:&lt;/P&gt;
&lt;PRE&gt;/* Step 1 - set all data together, and put year in as a data item */
data inter;
  set hyptabs.src_utah_vitals: indsname=tmp;
  year=scan(tmp,4,"_");
run;

/* Transpose the data */
proc transpose data=inter out=want;
  by year;
  var value;
  idlabel measure;
run;&lt;/PRE&gt;
&lt;P&gt;This shows a couple of things:&lt;BR /&gt;1) Why putting data into dataset names/variables is not a good idea.&amp;nbsp; If you keep data in the body of the table you can use it, manipulate it etc.&amp;nbsp; From a programmer point of view, data in names is really bad as it makes all programming far more difficult.&lt;/P&gt;
&lt;P&gt;2) Using : means all items with a prefix of&lt;/P&gt;
&lt;P&gt;3) Transpose procedure - this is designed to move data from long to wide or from wide to long.&amp;nbsp; Unless your data has multiple variables, it is the ideal solution for this (for multiple variables array approach is ideal).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 11:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411874#M3944</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-09T11:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411879#M3946</link>
      <description>&lt;P&gt;MERGE is for combining datasets with different variables (but maybe sharing one or more key variables) side-by-side.&lt;/P&gt;
&lt;P&gt;If you have identically structured datasets with data from different ranges, you use a simple SET statement to "stack" them.&lt;/P&gt;
&lt;P&gt;If you want to convert to a wide format, use a data step with by processing and retain. The details depend on the structure of the initial dataset. Right now I'm not sure at all what your dataset looks like.&lt;/P&gt;
&lt;P&gt;Post your existing dataset in a data step for testing. Use the macro from&amp;nbsp;&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 provide the datastep.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 11:45:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411879#M3946</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-11-09T11:45:13Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411981#M3947</link>
      <description>&lt;P&gt;Ok, that makes sense, but I still can't get it to work. Just to give you a better idea, here are all the columns of my data. Even though the SSNs are fake, I just grayed them out so no one gets worried.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-11-09 at 08.45.47.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16552i57EE65F0EF00B16F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-11-09 at 08.45.47.png" alt="Screen Shot 2017-11-09 at 08.45.47.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class=" block-mark"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=" block-mark"&gt;&lt;P&gt;I guess I am confused by the fact that we are using "by year".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code I tried, but maybe this is not what you were thinking.&lt;/P&gt;&lt;/DIV&gt;&lt;DIV class=" block-mark"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=" block-mark"&gt;&lt;SPAN class="sec-keyword"&gt;data&lt;/SPAN&gt;&lt;SPAN class="text"&gt; WORK.Vitals_Utah&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="keyword"&gt;set&lt;/SPAN&gt;&lt;SPAN class="text"&gt; HypTabs.Src_Utah_Vitals_2010&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="text"&gt;HypTabs.Src_Utah_Vitals_2011&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="text"&gt;HypTabs.Src_Utah_Vitals_2012&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="text"&gt;HypTabs.Src_Utah_Vitals_2013&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="text"&gt;HypTabs.Src_Utah_Vitals_2014&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;:&lt;/SPAN&gt; &lt;SPAN class="keyword"&gt;indsname&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text"&gt;tmp&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="text"&gt;year&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text"&gt;scan&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;(&lt;/SPAN&gt;&lt;SPAN class="text"&gt;tmp&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;,&lt;/SPAN&gt;&lt;SPAN class="numeric"&gt;4&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;,&lt;/SPAN&gt;&lt;SPAN class="string"&gt;"_"&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="sec-keyword"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=" block-mark"&gt;&lt;SPAN class="sec-keyword"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="sec-keyword"&gt;transpose&lt;/SPAN&gt; &lt;SPAN class="keyword"&gt;data&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text"&gt;WORK.Vitals_Utah &lt;/SPAN&gt;&lt;SPAN class="keyword"&gt;out&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;=&lt;/SPAN&gt;&lt;SPAN class="text"&gt;WORK.Vitals_Ut&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="keyword"&gt;by&lt;/SPAN&gt;&lt;SPAN class="text"&gt; year&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="keyword"&gt;var&lt;/SPAN&gt;&lt;SPAN class="text"&gt; value&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="keyword"&gt;idlabel&lt;/SPAN&gt;&lt;SPAN class="text"&gt; measure&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class="sec-keyword"&gt;run&lt;/SPAN&gt;&lt;SPAN class="sep"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 09 Nov 2017 15:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/411981#M3947</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T15:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412000#M3948</link>
      <description>&lt;P&gt;I was eventually able to get the right format with this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data work.Vitals_UtPre;&lt;BR /&gt;set&amp;nbsp;HypTabs.Src_Utah_Vitals_2010&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2011&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2012&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2013&lt;BR /&gt;HypTabs.Src_Utah_Vitals_2014;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort;&lt;BR /&gt;by SSN ApptDate;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc transpose&lt;BR /&gt;data&amp;nbsp;= WORK.Vitals_UtPre&lt;BR /&gt;out= WORK.Vitals_Ut;&lt;BR /&gt;by&amp;nbsp;SSN ApptDate;&lt;BR /&gt;var&amp;nbsp;Value;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My only question now is where would I put my rename statement to get these renames done. I have tried some options and it didn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(RENAME (ApptDate = VisitDt&lt;BR /&gt;SSN = SSN1&lt;BR /&gt;COL1 = HtIn&lt;BR /&gt;COL2 = WtLb&lt;BR /&gt;COL3 = SBP&lt;BR /&gt;COL4 = DBP));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412000#M3948</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T16:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412004#M3949</link>
      <description>&lt;P&gt;That's in a the format of a data set option.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Data set options go after the data set you want to modify, so place it after the name of the output data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose
data = WORK.Vitals_UtPre
out= WORK.Vitals_Ut &lt;SPAN&gt;(RENAME (ApptDate = VisitDt&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SSN = SSN1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COL1 = HtIn&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COL2 = WtLb&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COL3 = SBP&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;COL4 = DBP))&lt;/SPAN&gt;;&lt;BR /&gt;
by SSN ApptDate;
var Value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412004#M3949</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T16:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412006#M3950</link>
      <description>&lt;P&gt;But...you should also look at the ID statement within PROC TRANSPOSE to ID your&amp;nbsp;variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try adding the following. I don't think the names are exactly waht you want though, so you could either create a new variable earlier - the preferred approach in my opinion, or rename after. The rename after, relies on knowing the order but there's a small chance that could break.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ID Measure;
idlabel measure;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412006#M3950</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T16:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412008#M3951</link>
      <description>&lt;P&gt;Yes, you would need to sort it, sorry, I should have thought of that - its what happens if I can't test things.&amp;nbsp; Put your rename on the datastep - also note how I use the code window which is the {i} above the post area, and format my code for readability - i.e. avoid using mixed case.&amp;nbsp; A final point, it seems to me like the requirement changed somewhere, are you now saying that there is a variable in the data which holds the year value?&amp;nbsp; If so then we can simplify it:&lt;/P&gt;
&lt;PRE&gt;/* Step 1 - set all data together, and put year in as a data item */
data inter;
  set hyptabs.src_utah_vitals: ;   /* See here I use : to mean all datasets with that prefix */
run;&lt;BR /&gt;&lt;BR /&gt;proc sort data=inter;&lt;BR /&gt;  by apptdata;&lt;BR /&gt;run;

/* Transpose the data */
proc transpose data=inter out=want;
  by year;
  var value;
  idlabel measure;   
run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;  set want (rename=(apptdate=visitdt ssn=ssn1 col1=htln ...));&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:44:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412008#M3951</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-09T16:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412027#M3952</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;DATA WORK.Vitals_UtPre;
  SET HypTabs.Src_Utah_Vitals_2010
      HypTabs.Src_Utah_Vitals_2011
	  HypTabs.Src_Utah_Vitals_2012
	  HypTabs.Src_Utah_Vitals_2013
	  HypTabs.Src_Utah_Vitals_2014;
RUN;

PROC SORT;
	BY SSN ApptDate;
RUN;

PROC TRANSPOSE
	DATA = WORK.Vitals_UtPre
	OUT= WORK.Vitals_UT;
  	ID Measure;
	IDLABEL Measure;
  	BY SSN ApptDate;
  	VAR Value;
  
RUN;

DATA	WORK.Vitals_UT (RENAME	(ApptDate = VisitDt
		    SSN = SSN1
		    Height__In_ = HtIn
		    Weight__Lb_ = WtLb
		    Systolic_BP = SBP
		   	Dystolic_BP = DBP));
	RETAIN SSN VisitDt HtIn WtLb SBP DBP;
	
	SSN2	= INPUT(SSN1, 12.);
	SSN	= PUT(SSN1, SSN11.);
	
	KEEP SSN VisitDt HtIn WtLb SBP DBP;

	LABEL SSN = "Social Security Number"
		  VisitDt = "Visit Date"
		  HtIn = "Height (In)"
		  WtLb = "Weight (Lb)"
		  SBP = "Systolic BP (mmHg)"
		  DBP = "Diastolic BP (mmHg)";
	
	KEEP SSN VisitDt HtIn WtLb SBP DBP;

PROC SORT;
	BY SSN VisitDt;
RUN;&lt;/PRE&gt;&lt;P&gt;This is my whole code right now. I am just not able to get the rename statement to work. The ID statement works, but ultimately does not make the variable names I want, so I still included the rename statement.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 16:59:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412027#M3952</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T16:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412035#M3953</link>
      <description>&lt;P&gt;Got it to work. Just had to add a SET statement and it was fine. Thanks so much for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412035#M3953</guid>
      <dc:creator>marianhabesland</dc:creator>
      <dc:date>2017-11-09T17:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: Combining five datasets</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412036#M3954</link>
      <description>&lt;P&gt;Your RENAME is in the wrong place. It's on the output data set but you likely want it in your code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;See the two different ways to have rename in the code below. If you use it as a data set option, it only applies at the end, but you're trying to rename it before...so either include it on the missing(?) SET statement or as a statement itself.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class (rename=age=age_years);

set sashelp.class;
run;


data class;
set sashelp.class;

rename age=age_years;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Nov 2017 17:08:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Combining-five-datasets/m-p/412036#M3954</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-11-09T17:08:34Z</dc:date>
    </item>
  </channel>
</rss>

