<?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: Assign the format of a variable to another variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461492#M117420</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*I am not sure want you want to get it but it may surely help;


data have;
/* a b and c is numeric */&amp;nbsp;
a=0;
b=.;
c=5000;

run;

proc format ;

value new_format 

.= "MISSING"
0-4999="LESS then 5000"
5000 ="5000 &amp;gt;"
;
run;

data want;
set have;
new_a=put(a,new_format.);
new_b=put(b,new_format.);
new_C=put(c,new_format.);

drop a b c;&lt;BR /&gt;&lt;BR /&gt;rename new_a=a new_b=b new_c=c;
run;


* note: if you have data already in char then use INPUT function and use $ sign in proc formate such as $new_format;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 11 May 2018 07:02:13 GMT</pubDate>
    <dc:creator>shahparth260</dc:creator>
    <dc:date>2018-05-11T07:02:13Z</dc:date>
    <item>
      <title>Assign the format of a variable to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461487#M117417</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have set up a format for a particular variable, along these lines:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;proc format;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value&amp;nbsp;cost_range&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "$0-$5,000"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0-5000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "$0-$5,000"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5001-10000&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; =&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "$5,001-$10,000";&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The underlying variable above is obviously numeric; however, I want to be able to assign the resulting&amp;nbsp;format as a character string to another variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example, I want cost_range_char to actually store $0-$5000 as a character string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any advice will be appreciated and liked promptly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;</description>
      <pubDate>Fri, 11 May 2018 06:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461487#M117417</guid>
      <dc:creator>markc</dc:creator>
      <dc:date>2018-05-11T06:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the format of a variable to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461491#M117419</link>
      <description>&lt;P&gt;Use the put() function with your format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;cost_range_char = put(cost,cost_range.);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 May 2018 06:57:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461491#M117419</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-11T06:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Assign the format of a variable to another variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461492#M117420</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*I am not sure want you want to get it but it may surely help;


data have;
/* a b and c is numeric */&amp;nbsp;
a=0;
b=.;
c=5000;

run;

proc format ;

value new_format 

.= "MISSING"
0-4999="LESS then 5000"
5000 ="5000 &amp;gt;"
;
run;

data want;
set have;
new_a=put(a,new_format.);
new_b=put(b,new_format.);
new_C=put(c,new_format.);

drop a b c;&lt;BR /&gt;&lt;BR /&gt;rename new_a=a new_b=b new_c=c;
run;


* note: if you have data already in char then use INPUT function and use $ sign in proc formate such as $new_format;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 May 2018 07:02:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-the-format-of-a-variable-to-another-variable/m-p/461492#M117420</guid>
      <dc:creator>shahparth260</dc:creator>
      <dc:date>2018-05-11T07:02:13Z</dc:date>
    </item>
  </channel>
</rss>

