<?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: Format error: variable not have the same format as in the input data? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545340#M150839</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error: Variable SITE2 in WORK.DATA1 does not have the same format as in the input data&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your code is referencing the same dataset twice. Once in the DATA= option and then again in the COVARIATES= option.&amp;nbsp; So it probably is complaining that when it goes to read it the second time it notices that in the dataset DATA1 does the variable SITE2 does NOT have the format SITE2. attached, but the data it is reading from the DATA= option it DOES have it attached because of the FORMAT statement included in the PROC step.&lt;/P&gt;
&lt;P&gt;What happens if you attach the format in the data set first and remove the FORMAT statement from the PROC step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets nolist lib=work;
modify data1;
  format site1 site1. site2 site2.;
run;
quit;

proc phreg data=DATA1; 
title "......";
class SITE1 SITE2/ ref=first;
model survtime*died(0)=SITE1 SITE2;
baseline covariates=DATA1 out=oversurv survival=_all_ /diradj group=SITE1;
hazardratio SITE1 / diff=ref cl=both;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 Mar 2019 18:18:08 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-03-22T18:18:08Z</dc:date>
    <item>
      <title>Format error: variable not have the same format as in the input data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545255#M150811</link>
      <description>&lt;P&gt;Hi ALL,&lt;/P&gt;&lt;P&gt;I have two variables called "SITE1" and "SITE2", and I wrote a format&amp;nbsp; for these 2 variables;&lt;/P&gt;&lt;P&gt;Unfortunately when I run PROC PHREG an error&amp;nbsp; on formating stoped the proc;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: Variable SITE2 in WORK.DATA1 does not have the same format as in the input data&lt;/P&gt;&lt;P&gt;How can I come across this situation???&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc format ;&lt;BR /&gt;value SITE1&lt;/P&gt;&lt;P&gt;1 = 'A'&lt;BR /&gt;2 = 'B'&lt;BR /&gt;3 = 'C'&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;value SITE2&lt;/P&gt;&lt;P&gt;1= 'D'&lt;BR /&gt;2 = 'F'&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc phreg data=DATA1;&amp;nbsp;&lt;BR /&gt;title "......";&lt;BR /&gt;class SITE1 SITE2/ ref=first;&lt;BR /&gt;model survtime*died(0)=SITE1 SITE2;&lt;BR /&gt;baseline covariates=DATA1 out=oversurv survival=_all_ /diradj group=SITE1;&lt;BR /&gt;format SITE1 SITE1.&lt;BR /&gt;SITE2 SITE2.;&lt;BR /&gt;hazardratio SITE1 / diff=ref cl=both;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error: Variable SITE2 in WORK.DATA1 does not have the same format as in the input data&lt;/P&gt;&lt;P&gt;what does that mean?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 15:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545255#M150811</guid>
      <dc:creator>Claire_panda</dc:creator>
      <dc:date>2019-03-22T15:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Format error: variable not have the same format as in the input data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545262#M150812</link>
      <description>&lt;P&gt;Your formats take a numeric variable and change their appearance as specified by the format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the error is probably that SITE2 is a character variable, and you can't apply a format designed for a numeric variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need a format designed for a character variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value $SITE2

'1'= 'D'
'2' = 'F'
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Mar 2019 15:30:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545262#M150812</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-22T15:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: Format error: variable not have the same format as in the input data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545331#M150836</link>
      <description>&lt;P&gt;Thank you!&lt;BR /&gt;&lt;BR /&gt;But I'm sure of the data type of SITE2 is numeric.&lt;BR /&gt;&lt;BR /&gt;To double check, I changed the format SITE2 for a character variable, then...&lt;BR /&gt;ERROR: The variable 'SITE2' has already been defined as numeric. The attempt to redefine the&lt;BR /&gt;variable type to character is ignored.&lt;/P&gt;&lt;P&gt;That's really weird&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 17:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545331#M150836</guid>
      <dc:creator>Claire_panda</dc:creator>
      <dc:date>2019-03-22T17:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Format error: variable not have the same format as in the input data?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545340#M150839</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;Error: Variable SITE2 in WORK.DATA1 does not have the same format as in the input data&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your code is referencing the same dataset twice. Once in the DATA= option and then again in the COVARIATES= option.&amp;nbsp; So it probably is complaining that when it goes to read it the second time it notices that in the dataset DATA1 does the variable SITE2 does NOT have the format SITE2. attached, but the data it is reading from the DATA= option it DOES have it attached because of the FORMAT statement included in the PROC step.&lt;/P&gt;
&lt;P&gt;What happens if you attach the format in the data set first and remove the FORMAT statement from the PROC step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc datasets nolist lib=work;
modify data1;
  format site1 site1. site2 site2.;
run;
quit;

proc phreg data=DATA1; 
title "......";
class SITE1 SITE2/ ref=first;
model survtime*died(0)=SITE1 SITE2;
baseline covariates=DATA1 out=oversurv survival=_all_ /diradj group=SITE1;
hazardratio SITE1 / diff=ref cl=both;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2019 18:18:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-error-variable-not-have-the-same-format-as-in-the-input/m-p/545340#M150839</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-22T18:18:08Z</dc:date>
    </item>
  </channel>
</rss>

