<?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: Apply Format to Variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837610#M36172</link>
    <description>&lt;P&gt;Did you not read any of the responses to your previous basically identical post &lt;A href="https://communities.sas.com/t5/New-SAS-User/Custom-format-statement-error/m-p/836844" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Custom-format-statement-error/m-p/836844&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run PROC CONTENTS on your data set.&lt;/P&gt;
&lt;P&gt;ANY of the variables reported as TYPE= NUM &lt;STRONG&gt;cannot use any format whose name starts with $.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Any of the variables reported as TYPE=Char cannot use any format whose name does not start with $.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$ in the format name means that the format is intended to apply to Character values. &lt;STRONG&gt;You&lt;/STRONG&gt; have to know the type of your variables before applying any format.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Oct 2022 07:05:28 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-10-10T07:05:28Z</dc:date>
    <item>
      <title>Apply Format to Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837574#M36165</link>
      <description>&lt;P&gt;I am trying to apply the smoking and treatment format to the smoker and treatment variable.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc freq data=fit1;
table smoke tx_status;
format smoke CSfmt. tx_status txfmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;79   libname hw4 '\\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4';
NOTE: Libref HW4 was successfully assigned as follows:
      Engine:        V9
      Physical Name: \\apporto.com\dfs\GWU\Users\kennedyhinnant_gwu\Downloads\Assignment 4
80   data fit1;
81   set hw4.fit1;
82   run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1 has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.01 seconds


83   proc format;
84   value $CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format $CSFMT is already on the library WORK.FORMATS.
NOTE: Format $CSFMT has been output.
85   value $txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format $TXFMT is already on the library WORK.FORMATS.
NOTE: Format $TXFMT has been output.
86   value $bmifmt 25-HIGH ="overweight" LOW -&amp;lt; 25="normal";
NOTE: 25 is a numeric field and a character format is defined.
NOTE: Format $BMIFMT is already on the library WORK.FORMATS.
NOTE: Format $BMIFMT has been output.
87   value $bmigrp LOW -&amp;lt; 18= 'underweight' 18 - 25 = 'normal' 25 &amp;lt;- HIGH = 'normal';
NOTE: 18 is a numeric field and a character format is defined.
NOTE: Format $BMIGRP is already on the library WORK.FORMATS.
NOTE: Format $BMIGRP has been output.
88   run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


89   proc means data =fit1 p25;

NOTE: There were 5813 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds


90   proc format;
91   value cobmdfmt 0.5450000-HIGH = 'Above';
NOTE: Format COBMDFMT is already on the library WORK.FORMATS.
NOTE: Format COBMDFMT has been output.
92   value blbmdfmt LOW -&amp;lt; 0.5420000 = 'less';
NOTE: Format BLBMDFMT is already on the library WORK.FORMATS.
NOTE: Format BLBMDFMT has been output.
93   run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


94   data fit1tmp;
95   set hw4.fit1;
96   run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1TMP has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


97   proc print data=fit1(obs=5);
98   var dob dov;
99   format dob dov mmddyy10.;
100  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


101  proc freq data=fit1;
102  table smoke tx_status;
103  format smoke $CSfmt. tx_status $txfmt.;
ERROR: You are trying to use the character format $TXFMT with the numeric variable tx_status in data
       set WORK.FIT1.
104  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Oct 2022 18:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837574#M36165</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-09T18:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format to Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837576#M36166</link>
      <description>&lt;P&gt;Define the format as numeric:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value txfmt 1 = "treatment" 0 = "Placebo";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Oct 2022 18:41:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837576#M36166</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-09T18:41:42Z</dc:date>
    </item>
    <item>
      <title>Format error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837585#M36169</link>
      <description>&lt;P&gt;I am trying to figure out why I keep getting this error message. I thought I applied the formats to me variables. However the error message is saying it cannot be found. What did I do wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&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;
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; 
proc format; 
value cobmdfmt 0.5450000-HIGH = 'Above';
value blbmdfmt LOW -&amp;lt; 0.5420000 = 'less'; 
run;
data fit1tmp;
set hw4.fit1;
run;
proc print data=fit1(obs=5);
var dob dov;
format dob dov mmddyy10.;
run;
 proc means data = fit1;
format smoker CSfmt. tx_status txfmt.;
run; 
proc freq data=fit1; 
table bmi;
format bmi bmifmt.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;&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
73   data fit1;
74   set hw4.fit1;
75   run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1 has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds


76   proc format;
77   value CSfmt 1 = 'Current Smokers' 0 = 'Nonsmokers';
NOTE: Format CSFMT is already on the library WORK.FORMATS.
NOTE: Format CSFMT has been output.
78   value txfmt 1 = "treatment" 0 = "Placebo";
NOTE: Format TXFMT is already on the library WORK.FORMATS.
NOTE: Format TXFMT has been output.
79   value $bmifmt 25-HIGH ="overweight" LOW -&amp;lt; 25="normal";
NOTE: 25 is a numeric field and a character format is defined.
NOTE: Format $BMIFMT is already on the library WORK.FORMATS.
NOTE: Format $BMIFMT has been output.
80   value $bmigrp LOW -&amp;lt; 18= 'underweight' 18 - 25 = 'normal' 25 &amp;lt;- HIGH = 'normal';
NOTE: 18 is a numeric field and a character format is defined.
NOTE: Format $BMIGRP is already on the library WORK.FORMATS.
NOTE: Format $BMIGRP has been output.
81   run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


82   proc means data =fit1 p25;

NOTE: There were 5813 observations read from the data set WORK.FIT1.
NOTE: PROCEDURE MEANS used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds


83   proc format;
84   value cobmdfmt 0.5450000-HIGH = 'Above';
NOTE: Format COBMDFMT is already on the library WORK.FORMATS.
NOTE: Format COBMDFMT has been output.
85   value blbmdfmt LOW -&amp;lt; 0.5420000 = 'less';
NOTE: Format BLBMDFMT is already on the library WORK.FORMATS.
NOTE: Format BLBMDFMT has been output.
86   run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


87   data fit1tmp;
88   set hw4.fit1;
89   run;

NOTE: There were 5813 observations read from the data set HW4.FIT1.
NOTE: The data set WORK.FIT1TMP has 5813 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.01 seconds


90   proc print data=fit1(obs=5);
91   var dob dov;
92   format dob dov mmddyy10.;
93   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


94    proc means data = fit1;
95   format smoker CSfmt. tx_status txfmt.;
96   run;

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


97   proc freq data=fit1;
98   table bmi;
99   format bmi bmifmt.;
ERROR: The format BMIFMT was not found or could not be loaded.
100  run;

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE FREQ used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sun, 09 Oct 2022 23:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837585#M36169</guid>
      <dc:creator>MisterJenn</dc:creator>
      <dc:date>2022-10-09T23:31:11Z</dc:date>
    </item>
    <item>
      <title>Re: Format error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837587#M36170</link>
      <description>&lt;P&gt;You need to define NUMERIC formats if you want to use them with numeric values.&lt;/P&gt;
&lt;P&gt;Also the last label for the second looks wrong.&amp;nbsp; Or if you actually did only want two labels just define two ranges, not three.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;value bmifmt 25-HIGH ="overweight" LOW -&amp;lt; 25="normal";
value bmigrp LOW -&amp;lt; 18= 'underweight' 18 - 25 = 'normal' 25 &amp;lt;- HIGH = 'overweight';&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 00:32:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837587#M36170</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-10-10T00:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Format error</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837600#M36171</link>
      <description>&lt;P&gt;I combined your posts, as they deal with essentially the same issue.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 05:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837600#M36171</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-10-10T05:07:12Z</dc:date>
    </item>
    <item>
      <title>Re: Apply Format to Variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837610#M36172</link>
      <description>&lt;P&gt;Did you not read any of the responses to your previous basically identical post &lt;A href="https://communities.sas.com/t5/New-SAS-User/Custom-format-statement-error/m-p/836844" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/Custom-format-statement-error/m-p/836844&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Run PROC CONTENTS on your data set.&lt;/P&gt;
&lt;P&gt;ANY of the variables reported as TYPE= NUM &lt;STRONG&gt;cannot use any format whose name starts with $.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Any of the variables reported as TYPE=Char cannot use any format whose name does not start with $.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;$ in the format name means that the format is intended to apply to Character values. &lt;STRONG&gt;You&lt;/STRONG&gt; have to know the type of your variables before applying any format.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Oct 2022 07:05:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Apply-Format-to-Variable/m-p/837610#M36172</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-10-10T07:05:28Z</dc:date>
    </item>
  </channel>
</rss>

