<?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 Build variable using other variables in SAS Health and Life Sciences</title>
    <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6776#M696</link>
    <description>I want to create a variable where the name should contain the value of another variable.&lt;BR /&gt;
&lt;BR /&gt;
Example :&lt;BR /&gt;
&lt;BR /&gt;
A=1;&lt;BR /&gt;
Within 1 data step, I want to create variable "SCALE1" where 1 represents the value of variable A.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestion is welcome</description>
    <pubDate>Wed, 06 Feb 2008 09:21:03 GMT</pubDate>
    <dc:creator>Rik</dc:creator>
    <dc:date>2008-02-06T09:21:03Z</dc:date>
    <item>
      <title>Build variable using other variables</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6776#M696</link>
      <description>I want to create a variable where the name should contain the value of another variable.&lt;BR /&gt;
&lt;BR /&gt;
Example :&lt;BR /&gt;
&lt;BR /&gt;
A=1;&lt;BR /&gt;
Within 1 data step, I want to create variable "SCALE1" where 1 represents the value of variable A.&lt;BR /&gt;
&lt;BR /&gt;
Any suggestion is welcome</description>
      <pubDate>Wed, 06 Feb 2008 09:21:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6776#M696</guid>
      <dc:creator>Rik</dc:creator>
      <dc:date>2008-02-06T09:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Build variable using other variables</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6777#M697</link>
      <description>Rik,&lt;BR /&gt;
&lt;BR /&gt;
Try this:&lt;BR /&gt;
&lt;BR /&gt;
data new;&lt;BR /&gt;
	A=1;&lt;BR /&gt;
	IF A = 1 THEN	CALL SYMPUT('var1','scale'||LEFT(PUT(A, 3.)));&lt;BR /&gt;
	&amp;amp;var1 =45;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=new;	&lt;BR /&gt;
run;</description>
      <pubDate>Wed, 06 Feb 2008 11:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6777#M697</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-02-06T11:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Build variable using other variables</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6778#M698</link>
      <description>a

Message was edited by: Rik</description>
      <pubDate>Wed, 06 Feb 2008 12:07:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6778#M698</guid>
      <dc:creator>Rik</dc:creator>
      <dc:date>2008-02-06T12:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Build variable using other variables</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6779#M699</link>
      <description>Hi Nilan,&lt;BR /&gt;
&lt;BR /&gt;
This seems to be working fine in the example you posted but I also want to make it work in following example :&lt;BR /&gt;
data test;&lt;BR /&gt;
   a=1;output;&lt;BR /&gt;
   a=2;output;&lt;BR /&gt;
   a=3;output;&lt;BR /&gt;
run;&lt;BR /&gt;
data new;&lt;BR /&gt;
    set test;&lt;BR /&gt;
    ......&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Unfortunally your solution does not cover this...&lt;BR /&gt;
But thanks for the effort.</description>
      <pubDate>Wed, 06 Feb 2008 12:15:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6779#M699</guid>
      <dc:creator>Rik</dc:creator>
      <dc:date>2008-02-06T12:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Build variable using other variables</title>
      <link>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6780#M700</link>
      <description>I have two thoughts on this topic.&lt;BR /&gt;
&lt;BR /&gt;
1) In the first solution, I'm surprised that call symput worked.  I thought that variable assignment could not be used in the data set in which it was assigned.  When I try the code myself, I get an error.&lt;BR /&gt;
&lt;BR /&gt;
2) It sounds like you want to take a list of data and transpose it into a set of columns with the column name defined, in part, by a variable.  To do this, I would suggest looking at the prefix option of PROC TRANSPOSE.&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
a=1;b=45; output;&lt;BR /&gt;
a=2;b=27; output;&lt;BR /&gt;
a=3;b=99; output;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc transpose data=test out=new prefix=Scale;&lt;BR /&gt;
	id a;&lt;BR /&gt;
	var b;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc print data=new; run;&lt;BR /&gt;
&lt;BR /&gt;
Hope this helps.</description>
      <pubDate>Wed, 06 Feb 2008 14:46:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Health-and-Life-Sciences/Build-variable-using-other-variables/m-p/6780#M700</guid>
      <dc:creator>1162</dc:creator>
      <dc:date>2008-02-06T14:46:53Z</dc:date>
    </item>
  </channel>
</rss>

