<?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 Variable Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-Variable-Error/m-p/838901#M331702</link>
    <description>&lt;P&gt;Formats have to be assigned in FORMAT statement. You can not do that in the VAR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you must close the table viewer before you run the code.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Oct 2022 06:39:29 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2022-10-17T06:39:29Z</dc:date>
    <item>
      <title>Format Variable Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Variable-Error/m-p/838895#M331698</link>
      <description>&lt;P&gt;I keep getting this error but I don't understand why. I formatted&amp;nbsp; the variables beforehand so I should be able to do a procprint using those formatted variables.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4';
data fit1;
set hw4.fit1;
run;
*Question (i-iv);
proc format; 
value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
value txfmt 1 = "treatment" 0 = "Placebo";
value bmifmt 25-HIGH ="overweight" LOW -&amp;lt; 25="normal";
value bmigrp LOW -&amp;lt; 18= 'underweight' 18 - 25 = 'normal' 25 &amp;lt;- HIGH = 'normal';
run;
proc means data =fit1 p25; 
*Quesition 1(v-vi);
proc format; 
value cobmdfmt 0.545-HIGH = 'Above';
value blbmdfmt LOW -&amp;lt; 0.542 = 'less'; 
run;
*Question 1(c);
data fit1tmp;
set hw4.fit1;
run;
*Question 1c(ii); 
proc print data=fit1(obs=5);
var dob dov;
format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
run;
*Question 1c(iii); 
proc print data=fit1(obs=5); 
var dob dov Csfmt. txfmt.;
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;NOTE: Libref HW4 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4
179  data fit1;
180  set hw4.fit1;
181  run;

ERROR: You cannot open WORK.FIT1.DATA for output access with member-level control because
WORK.FIT1.DATA is in use by you in resource environment ViewTable Window.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.01 seconds


182  *Question (i-iv);
183  proc format;
184  value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format CSFMT is already on the library WORK.FORMATS.
NOTE: Format CSFMT has been output.
185  value txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format TXFMT is already on the library WORK.FORMATS.
NOTE: Format TXFMT has been output.
186  value bmifmt 25-HIGH ="overweight" LOW -&amp;lt; 25="normal";
NOTE: Format BMIFMT is already on the library WORK.FORMATS.
NOTE: Format BMIFMT has been output.
187  value bmigrp LOW -&amp;lt; 18= 'underweight' 18 - 25 = 'normal' 25 &amp;lt;- HIGH = 'normal';
NOTE: Format BMIGRP is already on the library WORK.FORMATS.
NOTE: Format BMIGRP has been output.
188  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


189  proc means data =fit1 p25;
190  *Quesition 1(v-vi);

NOTE: There were 5813 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


191  proc format;
192  value cobmdfmt 0.545-HIGH = 'Above';
NOTE: Format COBMDFMT is already on the library WORK.FORMATS.
NOTE: Format COBMDFMT has been output.
193  value blbmdfmt LOW -&amp;lt; 0.542 = 'less';
NOTE: Format BLBMDFMT is already on the library WORK.FORMATS.
NOTE: Format BLBMDFMT has been output.
194  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


195  *Question 1(c);
196  data fit1tmp;
197  set hw4.fit1;
198  run;

ERROR: You cannot open WORK.FIT1TMP.DATA for output access with member-level control because
WORK.FIT1TMP.DATA is in use by you in resource environment ViewTable Window.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


199  *Question 1c(ii);
200  proc print data=fit1(obs=5);
201  var dob dov;
202  format dob dov mmddyy10. smoker CSfmt. tx_status txfmt.;
203  run;

NOTE: There were 5 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


204  *Question 1c(iii);
205  proc print data=fit1(obs=5);
206  var dob dov Csfmt. txfmt.;
                 ------
                 22
                 201
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, -, /, :, _ALL_, _CHARACTER_,
              _CHAR_, _NUMERIC_.
ERROR 201-322: The option is not recognized and will be ignored.
207  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Oct 2022 04:53:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Variable-Error/m-p/838895#M331698</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-17T04:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: Format Variable Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-Variable-Error/m-p/838901#M331702</link>
      <description>&lt;P&gt;Formats have to be assigned in FORMAT statement. You can not do that in the VAR statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And you must close the table viewer before you run the code.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Oct 2022 06:39:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-Variable-Error/m-p/838901#M331702</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-17T06:39:29Z</dc:date>
    </item>
  </channel>
</rss>

