<?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 variable has different formats,  how can I retain all formatted values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38038#M7614</link>
    <description>I have two datasets gender and stage and common variable called category.  &lt;BR /&gt;
But in the gender dataset this variable has got a format gender where as in the other dataset the same variale has different format called stage.&lt;BR /&gt;
But when I am setting these two datasets, SAS takes format from the first dataset only and applies the same format for the values in the other dataset.&lt;BR /&gt;
But I want to retain the formatted values in both datasets when I am concatenating two datasets. How can I achieve this?</description>
    <pubDate>Mon, 11 Aug 2008 09:19:32 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2008-08-11T09:19:32Z</dc:date>
    <item>
      <title>variable has different formats,  how can I retain all formatted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38038#M7614</link>
      <description>I have two datasets gender and stage and common variable called category.  &lt;BR /&gt;
But in the gender dataset this variable has got a format gender where as in the other dataset the same variale has different format called stage.&lt;BR /&gt;
But when I am setting these two datasets, SAS takes format from the first dataset only and applies the same format for the values in the other dataset.&lt;BR /&gt;
But I want to retain the formatted values in both datasets when I am concatenating two datasets. How can I achieve this?</description>
      <pubDate>Mon, 11 Aug 2008 09:19:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38038#M7614</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2008-08-11T09:19:32Z</dc:date>
    </item>
    <item>
      <title>Re: variable has different formats,  how can I retain all formatted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38039#M7615</link>
      <description>If I understand well, you concatenate the two datasets with a SET statement. The common variable had different formats in the separate datasets, is that correct ?&lt;BR /&gt;
You cannot have two formats on a single variable, depending on the observation. But what you can do is create a character variable, using a PUT statement that will apply the correct format depending on the origin of the observation.&lt;BR /&gt;
Something like :[pre]&lt;BR /&gt;
DATA work.concat ;&lt;BR /&gt;
  SET work.gender (IN = in_gender) work.stage (IN = in_stage) ;&lt;BR /&gt;
  IF in_gender THEN char_var = PUT(category, gender.) ;&lt;BR /&gt;
  ELSE char_var = PUT(category, stage.) ;&lt;BR /&gt;
RUN ;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
Regards&lt;BR /&gt;
Olivier</description>
      <pubDate>Mon, 11 Aug 2008 09:41:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38039#M7615</guid>
      <dc:creator>Olivier</dc:creator>
      <dc:date>2008-08-11T09:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: variable has different formats,  how can I retain all formatted values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38040#M7616</link>
      <description>You can store the formatted value in a seperate column, something like this:&lt;BR /&gt;
&lt;BR /&gt;
data genderstage;&lt;BR /&gt;
	set gender (in=g) stage (in=s);&lt;BR /&gt;
	if g then gendFmt = put(gender,$gendFmt.)&lt;BR /&gt;
	else gendFmt = put(gender,$stageFmt.);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Mon, 11 Aug 2008 10:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/variable-has-different-formats-how-can-I-retain-all-formatted/m-p/38040#M7616</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2008-08-11T10:25:11Z</dc:date>
    </item>
  </channel>
</rss>

