<?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: How to assign the same attribute to new variables by copy the existing variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521913#M141642</link>
    <description>&lt;P&gt;So did you actually try my suggestion, or did you just decide that it wouldn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if 5=4 then agenew = age;&lt;/P&gt;</description>
    <pubDate>Mon, 17 Dec 2018 14:01:11 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-12-17T14:01:11Z</dc:date>
    <item>
      <title>How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521901#M141636</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to apply same attributes what ever we have for “age” variable to “agenew” variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I don't want to create any macro/macro variable for this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I need to do this in same data set.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; agenew = put(age,best.);&lt;/P&gt;&lt;P&gt;run ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:38:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521901#M141636</guid>
      <dc:creator>bhanuprakash</dc:creator>
      <dc:date>2018-12-17T13:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521903#M141637</link>
      <description>&lt;P&gt;If you want the same values, just use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;agenew = age;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you just want the attributes and not the values, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if 5=4 then agenew = age;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This requires that AGENEW is not yet part of the incoming data.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521903#M141637</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-17T13:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521905#M141638</link>
      <description>&lt;P&gt;Not possible in any way. age is numeric, agenew will be character by definition, so there's no way they could have the same attributes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:43:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521905#M141638</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-17T13:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521908#M141639</link>
      <description>&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry to say that but my question is completely different.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to apply the same attributes(length, type, informat and format etc ) what ever we have for “age” variable to “agenew” variable.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 13:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521908#M141639</guid>
      <dc:creator>bhanuprakash</dc:creator>
      <dc:date>2018-12-17T13:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521913#M141642</link>
      <description>&lt;P&gt;So did you actually try my suggestion, or did you just decide that it wouldn't work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if 5=4 then agenew = age;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 14:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521913#M141642</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-12-17T14:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521920#M141643</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
merge
  sashelp.class
  sashelp.class (keep=age rename=(age=agenew))
;
agenew = .; /* add any processing you want to do, but make sure you get results of the correct type */
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Dec 2018 14:24:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521920#M141643</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-12-17T14:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521923#M141645</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124649"&gt;@bhanuprakash&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to apply same attributes what ever we have for “age” variable to “agenew” variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I don't want to create any macro/macro variable for this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I need to do this in same data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set sashelp.class;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; agenew = put(age,best.);&lt;/P&gt;
&lt;P&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;There are no commands to clone the attributes of a variable, except using the merge suggested by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;. The functions open, attrn and attrc can read the attributes of a variable, but there are no functions to change those attributes in a datastep.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Dec 2018 14:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/521923#M141645</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-12-17T14:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign the same attribute to new variables by copy the existing variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/576346#M163121</link>
      <description>&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/124649"&gt;@bhanuprakash&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to apply same attributes what ever we have for “age” variable to “agenew” variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I don't want to create any macro/macro variable for this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I need to do this in same data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;set sashelp.class;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; agenew = put(age,best.);&lt;/P&gt;
&lt;P&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You can convert numeric to character using PROC TRANSPOSE.&amp;nbsp; For example.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=sashelp.class(obs=3)  out=flip;
   by name;
   var sex--weight;
   copy sex--weight; 
   attrib _all_ label='Example Label';
   format _numeric_ 8.2;
   run;
proc print data=flip(obs=10);
   run;
proc transpose data=flip out=flop(drop=_:) prefix=New_;
   by name;
   copy sex--weight;
   id _name_;
   idlabel _label_;
   var col1;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&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="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31272iD936FE3E96FB3769/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 344px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/31273i1CCD6FFAEB4DD952/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 19:55:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-assign-the-same-attribute-to-new-variables-by-copy-the/m-p/576346#M163121</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2019-07-24T19:55:38Z</dc:date>
    </item>
  </channel>
</rss>

