<?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: Converting from wide to long and creating new variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387896#M93028</link>
    <description>Hi Reeza, maybe my post isn't clear. Essentially, I want the dataset to look like this:&lt;BR /&gt;ID HEDIS Time&lt;BR /&gt;1 40 -15&lt;BR /&gt;1 35 -14&lt;BR /&gt;1 35 -13&lt;BR /&gt;...&lt;BR /&gt;1 36 14&lt;BR /&gt;1 37 15&lt;BR /&gt;&lt;BR /&gt;Where the Time variable is based on the HEDIS_15 and etc. variables in the wide dataset (HEDIS_15 is Time -15 and HEDIS15 is Time 15).</description>
    <pubDate>Mon, 14 Aug 2017 18:01:36 GMT</pubDate>
    <dc:creator>corkee</dc:creator>
    <dc:date>2017-08-14T18:01:36Z</dc:date>
    <item>
      <title>Converting from wide to long and creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387884#M93025</link>
      <description>&lt;P&gt;Hi, I reshaped my dataset from long to wide and now need to change it back to long. The code I used to convert from long to wide is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=medicaid_new;
	by ParticipantID;
run;

proc transpose data=medicaid_new out=medicaid_wide1 prefix=HEDIS;
	by ParticipantID;
	id Time;
	var HEDIS;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The time variable has values ranging from -15 to 15. Is it possible to reshape it from wide to long and to create a new "Time" variable with its original values? In wide format, the HEDIS variables are called: HEDIS_15 for Time = -15, HEDIS_14 for Time = -14, ... HEDIS15 for Time = 15. Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 17:51:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387884#M93025</guid>
      <dc:creator>corkee</dc:creator>
      <dc:date>2017-08-14T17:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from wide to long and creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387891#M93027</link>
      <description>&lt;P&gt;No, SAS variables need to start with a letter or _.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can assign the label though, using the IDLABEL statement.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 17:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387891#M93027</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-14T17:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from wide to long and creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387896#M93028</link>
      <description>Hi Reeza, maybe my post isn't clear. Essentially, I want the dataset to look like this:&lt;BR /&gt;ID HEDIS Time&lt;BR /&gt;1 40 -15&lt;BR /&gt;1 35 -14&lt;BR /&gt;1 35 -13&lt;BR /&gt;...&lt;BR /&gt;1 36 14&lt;BR /&gt;1 37 15&lt;BR /&gt;&lt;BR /&gt;Where the Time variable is based on the HEDIS_15 and etc. variables in the wide dataset (HEDIS_15 is Time -15 and HEDIS15 is Time 15).</description>
      <pubDate>Mon, 14 Aug 2017 18:01:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387896#M93028</guid>
      <dc:creator>corkee</dc:creator>
      <dc:date>2017-08-14T18:01:36Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from wide to long and creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387925#M93038</link>
      <description>&lt;P&gt;Yeah, sorry, didn't catch that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use COMPRESS() within a second data step to remove the letters then and keep the numbers and - symbol.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 19:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/387925#M93038</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-14T19:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Converting from wide to long and creating new variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/388047#M93080</link>
      <description>&lt;P&gt;Simpler to use a data step in ths case:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data medicaid_long;
set medicaid_wide;
array h hedis_15 -- hedis15;
do time = -15 to 15;
	HEDIS = h{time};
	output;
	end;
keep participantID time HEDIS;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Aug 2017 03:20:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Converting-from-wide-to-long-and-creating-new-variable/m-p/388047#M93080</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2017-08-15T03:20:54Z</dc:date>
    </item>
  </channel>
</rss>

