<?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: Create Multiple Variables from Observations with a Common Identifier in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802320#M315844</link>
    <description>&lt;P&gt;Usually, turning a long data set to a wide data set is a poor choice, and harder to handle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What analysis/table/report are you trying to create with this data?&lt;/P&gt;</description>
    <pubDate>Tue, 15 Mar 2022 19:16:21 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-03-15T19:16:21Z</dc:date>
    <item>
      <title>Create Multiple Variables from Observations with a Common Identifier</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802319#M315843</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset that has lab draws over the span of a few days (example below). I want to create a dataset that has a unique line for each patient, with variables iterating _1, _2, etc. for each draw. I have tried to use an array, but am not very experienced with them so any help is much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset I currently have:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Patient&lt;/TD&gt;&lt;TD&gt;ALT&lt;/TD&gt;&lt;TD&gt;AST&lt;/TD&gt;&lt;TD&gt;INR&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;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/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;48&lt;/TD&gt;&lt;TD&gt;1.03&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;TD&gt;.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;15&lt;/TD&gt;&lt;TD&gt;30&lt;/TD&gt;&lt;TD&gt;1.11&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;TD&gt;32&lt;/TD&gt;&lt;TD&gt;1.25&lt;/TD&gt;&lt;TD&gt;18&lt;/TD&gt;&lt;TD&gt;33&lt;/TD&gt;&lt;TD&gt;1.30&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 19:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802319#M315843</guid>
      <dc:creator>dgaribal</dc:creator>
      <dc:date>2022-03-15T19:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Variables from Observations with a Common Identifier</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802320#M315844</link>
      <description>&lt;P&gt;Usually, turning a long data set to a wide data set is a poor choice, and harder to handle.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What analysis/table/report are you trying to create with this data?&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 19:16:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802320#M315844</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-15T19:16:21Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Variables from Observations with a Common Identifier</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802327#M315847</link>
      <description>&lt;P&gt;I completely agree. I am just adjusting the data to fit into a historic database that was created long before I was working on it, so to fit it in I unfortunately need to make it wide.&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 19:36:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802327#M315847</guid>
      <dc:creator>dgaribal</dc:creator>
      <dc:date>2022-03-15T19:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Variables from Observations with a Common Identifier</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802466#M315909</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Patient ALT AST INR;
cards;
1 20 24 1.01
1 33 48 1.03
2 15 30 1.11
2 17 32 1.25
2 18 33 1.30
;

data temp;
 set have;
 by Patient;
 if first.Patient then n=0;
 n+1;
run;

proc transpose data=temp out=temp2;
by  Patient n;
var ALT AST INR ;
run;
proc transpose data=temp2 out=want(drop=_NAME_) delimiter=_;
by Patient ;
id _NAME_ n;
var col1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Mar 2022 12:02:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802466#M315909</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-03-16T12:02:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create Multiple Variables from Observations with a Common Identifier</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802505#M315933</link>
      <description>&lt;P&gt;This worked great! Thank you so much, I really appreciate it.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 16:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-Multiple-Variables-from-Observations-with-a-Common/m-p/802505#M315933</guid>
      <dc:creator>dgaribal</dc:creator>
      <dc:date>2022-03-16T16:13:16Z</dc:date>
    </item>
  </channel>
</rss>

