<?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: keeping original and formatted value together in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252072#M47750</link>
    <description>&lt;P&gt;Here is one example from my side, you could also do merging, i.e. merge on code=x which would be less resource hunry on bigger datasets as in the second example:&lt;/P&gt;
&lt;PRE&gt;data codes;
  code=1; decode="good"; output;
  code=2; decode="bad"; output;
run;

data have;
	input x;
	cards;
 1
 2
;
run;

proc sql;&lt;BR /&gt; create table WANT as&lt;BR /&gt; select X,&lt;BR /&gt; (select THIS.DECODE from CODES THIS where THIS.CODE=X) as DECODED_VALUE&lt;BR /&gt; from HAVE;&lt;BR /&gt; create table WANT2 as&lt;BR /&gt; select A.X, &lt;BR /&gt; B.DECODE as DECODED_VALUE&lt;BR /&gt; from HAVE A&lt;BR /&gt; left join CODES B&lt;BR /&gt; on A.X=B.CODE;&lt;BR /&gt;quit;&lt;/PRE&gt;</description>
    <pubDate>Wed, 24 Feb 2016 15:38:13 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2016-02-24T15:38:13Z</dc:date>
    <item>
      <title>keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252056#M47741</link>
      <description>&lt;P&gt;I am trying to put original variable and formatted variable values together. &amp;nbsp;This does not work since I have to format the original value. Is there a way to get around this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
	value  type
		1="good"
		2="bad";
run;

data have;
	input x;
	cards;
 1
 2
 ;

data want;
	set have;
	format x type.;
	y='x';
	test1=vvalue(x);
	test2=vvaluex(y);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Desired output:&lt;/P&gt;&lt;P&gt;x &amp;nbsp; &amp;nbsp; test1 test2&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp;good &amp;nbsp;good&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp;bad &amp;nbsp; &amp;nbsp;bad&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 14:49:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252056#M47741</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-02-24T14:49:50Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252058#M47742</link>
      <description>&lt;P&gt;Use the put() function:&lt;/P&gt;
&lt;PRE&gt;data want;
	set have;
	test1=put(x,type.);
	test2=put(x,type.);
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 14:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252058#M47742</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-24T14:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252062#M47743</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;&amp;nbsp; Thank you. I guess I was thinking hard.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:03:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252062#M47743</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-02-24T15:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252063#M47744</link>
      <description>&lt;P&gt;Make a new copy of the format where the decode includes the codes. &amp;nbsp;So&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value type
 1="good"
 2="bad"
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is converted to&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value type
 1="1 good"
 2="2 bad"
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Personally I have a utility macro that will convert a format catalog. So if I had a catalog name MYLIB.FORMATS I can run the macro and generate a catalog MYLIB.CFORMATS. &amp;nbsp;Then I can just change the FMTSEARCH option. &amp;nbsp;So when I am writing my program and debugging I can use the CFORMATS version and see the code so I know how to write my IF and WHERE statements. &amp;nbsp;Then when I produce the final report I can use the regular format catalog and the numbers do not appear.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:04:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252063#M47744</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-02-24T15:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252067#M47746</link>
      <description>&lt;P&gt;Yep, another options is to not use formats at all, put code and decode in a dataset. &amp;nbsp;CDISC has this kind of approach as its XML based, and it would be my preferred approach to avoid proprietary file formats, which as shown by the debacle of 32 and 64 bit catalogs goes to show.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:11:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252067#M47746</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-24T15:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252071#M47749</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom﻿&lt;/a&gt;&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9﻿&lt;/a&gt;. &amp;nbsp;Thank you. Is there an example that I can follow if possible?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:24:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252071#M47749</guid>
      <dc:creator>SAS_inquisitive</dc:creator>
      <dc:date>2016-02-24T15:24:18Z</dc:date>
    </item>
    <item>
      <title>Re: keeping original and formatted value together</title>
      <link>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252072#M47750</link>
      <description>&lt;P&gt;Here is one example from my side, you could also do merging, i.e. merge on code=x which would be less resource hunry on bigger datasets as in the second example:&lt;/P&gt;
&lt;PRE&gt;data codes;
  code=1; decode="good"; output;
  code=2; decode="bad"; output;
run;

data have;
	input x;
	cards;
 1
 2
;
run;

proc sql;&lt;BR /&gt; create table WANT as&lt;BR /&gt; select X,&lt;BR /&gt; (select THIS.DECODE from CODES THIS where THIS.CODE=X) as DECODED_VALUE&lt;BR /&gt; from HAVE;&lt;BR /&gt; create table WANT2 as&lt;BR /&gt; select A.X, &lt;BR /&gt; B.DECODE as DECODED_VALUE&lt;BR /&gt; from HAVE A&lt;BR /&gt; left join CODES B&lt;BR /&gt; on A.X=B.CODE;&lt;BR /&gt;quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Feb 2016 15:38:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/keeping-original-and-formatted-value-together/m-p/252072#M47750</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-02-24T15:38:13Z</dc:date>
    </item>
  </channel>
</rss>

