<?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: Large dataset: Creating one variable (column) from multiple years of data in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734993#M80408</link>
    <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;BR /&gt;Thanks for your advice! This is the right idea, however I am looking for it to be the actual data (health condition e.g., ABC) in each cell that is listed rather than the column name. I am sure there is a way to do this, but can't seem to figure it out. My code and output using PROC TRANSPOSE is shown below, please refer to my original post for what I would like my data to look like!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;PROC TRANSPOSE&lt;/STRONG&gt; data=file out=file_transposed;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var Year_1 Year_2 Year_3 Year_4 Year_5;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by PatientID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PatientID. NAME&lt;BR /&gt;1. Year 1&lt;BR /&gt;1. Year 2&lt;BR /&gt;1. Year 3&lt;BR /&gt;1. Year 4&lt;BR /&gt;1. Year 5&lt;BR /&gt;2. Year 1&lt;BR /&gt;2. Year 2&lt;BR /&gt;2. Year 3&lt;BR /&gt;2. Year 4&lt;BR /&gt;2. Year 5&lt;BR /&gt;3. Year 1&lt;BR /&gt;3. Year 2&lt;BR /&gt;3. Year 3&lt;BR /&gt;3. Year 4&lt;BR /&gt;3. Year 5&lt;/P&gt;</description>
    <pubDate>Sun, 18 Apr 2021 01:22:46 GMT</pubDate>
    <dc:creator>EMc</dc:creator>
    <dc:date>2021-04-18T01:22:46Z</dc:date>
    <item>
      <title>Large dataset: Creating one variable (column) from multiple years of data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734978#M80406</link>
      <description>&lt;P&gt;I have 180 columns containing the same character data reported each year over many years (from a longitudinal data set). &amp;nbsp; I am looking to combine these columns into one singular column so that I can compute two way frequencies etc. &amp;nbsp; I have looked into "append" however I understand this is for datasets not variables. &amp;nbsp;I have also tried a transpose, however I end up with 9000 columns (number of patients). &amp;nbsp;Other similar posts suggest an array for this type of data, however they all require you to enter datelines. &amp;nbsp;My dataset is much too large to record &amp;nbsp;each individual dateline! &amp;nbsp; Hope someone has insight as to how to do this, or possibly a better method!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Current Data:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Patient ID &amp;nbsp; &amp;nbsp; &amp;nbsp;Year 1. &amp;nbsp; &amp;nbsp;Year 2. &amp;nbsp; &amp;nbsp;Year 3. &amp;nbsp; &amp;nbsp;Year 4. &amp;nbsp; Year 5&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ABB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp;BAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;2&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ACA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABA &amp;nbsp; &amp;nbsp; &amp;nbsp;AAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;ABB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ABA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ACA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp;AAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I want:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Patient ID &amp;nbsp; Health Condition&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABB &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;1. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;BAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ACA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABB &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABA &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;2. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABB&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ACA &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ABC &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;3. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;AAC &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 17 Apr 2021 23:27:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734978#M80406</guid>
      <dc:creator>EMc</dc:creator>
      <dc:date>2021-04-17T23:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Large dataset: Creating one variable (column) from multiple years of data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734979#M80407</link>
      <description>Use PROC TRANSPOSE with a BY PATIENTID; statement.</description>
      <pubDate>Sun, 18 Apr 2021 00:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734979#M80407</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-18T00:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: Large dataset: Creating one variable (column) from multiple years of data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734993#M80408</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&lt;BR /&gt;Thanks for your advice! This is the right idea, however I am looking for it to be the actual data (health condition e.g., ABC) in each cell that is listed rather than the column name. I am sure there is a way to do this, but can't seem to figure it out. My code and output using PROC TRANSPOSE is shown below, please refer to my original post for what I would like my data to look like!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;PROC TRANSPOSE&lt;/STRONG&gt; data=file out=file_transposed;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var Year_1 Year_2 Year_3 Year_4 Year_5;&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;by PatientID;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PatientID. NAME&lt;BR /&gt;1. Year 1&lt;BR /&gt;1. Year 2&lt;BR /&gt;1. Year 3&lt;BR /&gt;1. Year 4&lt;BR /&gt;1. Year 5&lt;BR /&gt;2. Year 1&lt;BR /&gt;2. Year 2&lt;BR /&gt;2. Year 3&lt;BR /&gt;2. Year 4&lt;BR /&gt;2. Year 5&lt;BR /&gt;3. Year 1&lt;BR /&gt;3. Year 2&lt;BR /&gt;3. Year 3&lt;BR /&gt;3. Year 4&lt;BR /&gt;3. Year 5&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 01:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/734993#M80408</guid>
      <dc:creator>EMc</dc:creator>
      <dc:date>2021-04-18T01:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: Large dataset: Creating one variable (column) from multiple years of data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/735002#M80409</link>
      <description>&lt;P&gt;It works for me&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover dsd dlm=' ';
  input (Patient_ID Year_1 Year_2 Year_3 Year_4 Year_5) ($);
  datalines;
1 ABC ABB ABA ABC BAC
2 ACA ABC ABB ABA AAC
3 ABB ABA ACA ABC AAC
;

PROC TRANSPOSE data=have out=want name=Year prefix=Health_Condition;
  var Year_1 Year_2 Year_3 Year_4 Year_5;
  by Patient_ID;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1618711331326.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58238i16070E50E8D051CD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1618711331326.png" alt="Patrick_0-1618711331326.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or here a data step approach which I would expect to perform better.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want2;
  set have;
  array _y {*} year_:;
  do _i=1 to dim(_y);
    Year=input(vname(_y[_i]),$6.);
    Health_Condition=_y[_i];
    output;
  end;
  keep Patient_ID Year Health_Condition;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Apr 2021 02:08:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/735002#M80409</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-04-18T02:08:25Z</dc:date>
    </item>
    <item>
      <title>Re: Large dataset: Creating one variable (column) from multiple years of data</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/735131#M80410</link>
      <description>Thanks a lot! Data step was exactly what I needed.</description>
      <pubDate>Sun, 18 Apr 2021 21:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Large-dataset-Creating-one-variable-column-from-multiple-years/m-p/735131#M80410</guid>
      <dc:creator>EMc</dc:creator>
      <dc:date>2021-04-18T21:18:35Z</dc:date>
    </item>
  </channel>
</rss>

