<?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: proc formate for character variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864217#M341312</link>
    <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it cannot remove format it shows numeric only not actual F and M&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
input sex $ ;
datalines;
F
F
F
M
M
M
;
run;


proc format ;
value $gender 'F'=111 'M'=222;
run;


data new1;
set new;
format sex $gender.;
run;



proc datasets lib=work memtype=data;
modify new1;
attrib gender format= ;
run;
quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Mar 2023 05:31:53 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2023-03-15T05:31:53Z</dc:date>
    <item>
      <title>proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864201#M341300</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
value  $gen  'F'=1 'M'=2;
run;

data ds1;
set dsn;
format  sex $gen. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;how to format for character sex variable to numberic using proc format&lt;/P&gt;
&lt;P&gt;output M=1&amp;nbsp; &amp;nbsp; &amp;nbsp;and&amp;nbsp; &amp;nbsp; F=0&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 03:41:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864201#M341300</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-03-15T03:41:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864210#M341305</link>
      <description>&lt;P&gt;FORMATS control how values are DISPLAYED.&amp;nbsp; So formats always convert values into strings.&amp;nbsp; So your code should have been written this way to make that clearer to the programmer that had to read the code after you created it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  value  $gen  'F'='1' 'M'='2';
run;

data ds1;
  set dsn;
  format  sex $gen. ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;INFORMATS convert strings into values.&amp;nbsp; &amp;nbsp;So a CHARACTER informat creates character values and a NUMERIC informat creates numeric values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So to convert the string 'M' into the number 1 you need to use a numeric INFORMAT, not a character FORMAT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format ;
  invalue  gen  'F'=1 'M'=2 other=.;
run;

data ds1;
  set dsn;
  num_sex = input(sex,gen.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:29:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864210#M341305</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-15T04:29:08Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864211#M341306</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds;
set sashelp.class;
informat sex$ gen.;
run;

proc format ;
  invalue  gen  'F'=1 'M'=2 other=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i want to use proc fomat only not input or put functions to convert variable formats&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where i did wrong in the above syntax&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:33:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864211#M341306</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-03-15T04:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864212#M341307</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds;
set sashelp.class;
informat sex$ gen.;
run;

proc format ;
  invalue  gen  'F'=1 'M'=2 other=.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;i want to use proc fomat only not input or put functions to convert variable formats&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where i did wrong in the above syntax&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That data step makes no sense.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Changing the INFORMAT attached to a variable that already has values in it does nothing.&amp;nbsp; You are not reading any text and converting it into a value to store into SEX.&amp;nbsp; For that to happen you need to use either an INPUT statement or an INPUT() function call.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 04:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864212#M341307</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-15T04:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864215#M341310</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* how to define user formats char to numeric  */

proc format ;
value $gen 'F' =1 'M'=0;
run;


data ds;
set sashelp.class;
format sex $gen.;
run;



data new;
input sex $ ;
datalines;
F
F
F
M
M
M
;
run;


proc format ;
value $gender 'F'=111 'M'=222;
run;


data new1;
set new;
format sex $gender.;
run;
&lt;BR /&gt;*How to remove user define formats for particular datasets using proc datasets*&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;proc datasets lib=work memtype=data;&lt;BR /&gt;attrib gender format= ;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;hi Tom i got my required output above code&lt;/P&gt;
&lt;P&gt;but I can not remove format for new1 dataset using proc datasets attrib statment&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 15 Mar 2023 05:22:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864215#M341310</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-03-15T05:22:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864216#M341311</link>
      <description>&lt;P&gt;You need a MODIFY statement to tell proc datasets which data set in the library that you want to modify;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc datasets lib=work memtype=data;&lt;BR /&gt;modify new1;&lt;BR /&gt;attrib &lt;STRIKE&gt;gender&lt;/STRIKE&gt; sex format= ;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 07:48:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864216#M341311</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-15T07:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864217#M341312</link>
      <description>&lt;P&gt;Hi Ballardw&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it cannot remove format it shows numeric only not actual F and M&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data new;
input sex $ ;
datalines;
F
F
F
M
M
M
;
run;


proc format ;
value $gender 'F'=111 'M'=222;
run;


data new1;
set new;
format sex $gender.;
run;



proc datasets lib=work memtype=data;
modify new1;
attrib gender format= ;
run;
quit;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Mar 2023 05:31:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864217#M341312</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2023-03-15T05:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864219#M341314</link>
      <description>&lt;P&gt;If you want to&amp;nbsp;&lt;EM&gt;convert&lt;/EM&gt; a variable from character to numeric, you MUST use the INPUT function, period.&lt;/P&gt;
&lt;P&gt;If you want to keep the variable as is, but only change how it is&amp;nbsp;&lt;EM&gt;displayed&lt;/EM&gt;, assigning a format with PROC DATASETS will suffice.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 05:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864219#M341314</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-03-15T05:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864221#M341315</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/265860"&gt;@BrahmanandaRao&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi Ballardw&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it cannot remove format it shows numeric only not actual F and M&amp;nbsp;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;Wrong variable, your variable is SEX. I used gender as a test on a different data set.&lt;/P&gt;
&lt;P&gt;If you read your LOG you will see something similar to this stating so:&lt;/P&gt;
&lt;PRE&gt;646  proc datasets lib=work memtype=data;
647  modify new1;
&lt;FONT color="#008000"&gt;&lt;STRONG&gt;WARNING: Variable GENDER not found in data set WORK.NEW1.&lt;/STRONG&gt;&lt;/FONT&gt;
648  attrib gender format= ;
649  run;

NOTE: MODIFY was successful for WORK.NEW1.DATA.
650  quit;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 07:51:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864221#M341315</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-15T07:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc formate for character variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864273#M341342</link>
      <description>&lt;P&gt;The error message tells you want is wrong.&amp;nbsp; You tried to remove the format from a variable named GENDER, but the dataset does not have any variable with that name.&amp;nbsp; The variable you used in the other code you posted was named SEX.&amp;nbsp; GENDER as the name of the FORMAT you were trying to attach to the variable, and now appear to want to remove.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also please add the quotes around the label/decode values when writing your VALUE statements in PROC FORMAT.&amp;nbsp; I know that SAS will accept the statement without them (to maintain backwards compatibility with code written in the 1970's) but it just confuses humans to not have them.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-formate-for-character-variables/m-p/864273#M341342</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-03-15T13:15:48Z</dc:date>
    </item>
  </channel>
</rss>

