<?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: Creating a character format that is not case sensitive in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894121#M353207</link>
    <description>&lt;P&gt;Here is another option if you don't mind creating a new variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input string $;
cards;
married
Married
MARRIED
;
run;

proc format;
 value $stat "MARRIED"='M';
run;

data test;
set test;
string1=put(upcase(string),$stat.);
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Sep 2023 17:06:01 GMT</pubDate>
    <dc:creator>Kathryn_SAS</dc:creator>
    <dc:date>2023-09-13T17:06:01Z</dc:date>
    <item>
      <title>Creating a character format that is not case sensitive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894106#M353203</link>
      <description>I have a csv file where one of the variables is entered inconsistently in terms of capital and lower-case lettering (e.g. Married, married, MARRIED, ect.). I'm wanting to format the observations to be a single-letter value (e.g. M) for all case variants without including all variants in my code. Is there a way to tell SAS to ignore case sensitivity and focus on just the spelling when formatting the data? Open to work around as well.</description>
      <pubDate>Wed, 13 Sep 2023 15:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894106#M353203</guid>
      <dc:creator>jrleighty</dc:creator>
      <dc:date>2023-09-13T15:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a character format that is not case sensitive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894107#M353204</link>
      <description>&lt;P&gt;$UPCASE1. format?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input string $20.;
cards;
married
Married
Marrie
M
;
run;

proc print data=have;
var string;
format string $upcase1.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2023 15:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894107#M353204</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-09-13T15:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a character format that is not case sensitive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894115#M353205</link>
      <description>&lt;P&gt;How about an INFORMAT to read the data with?&lt;/P&gt;
&lt;P&gt;The Invalue used to create an informat has the option of upcase which converts all text to upper case before comparing to the list of values. The other=_error_ option means that any values encountered that you didn't expect generate and invalid data message in the log and let you know a bit sooner about such. I use that to update my informat, as needed, when my data sources are inconsistent. Such as adding Spanish spellings or their own custom abbreviation like "MAR". Which I would add to the range in my invalue.&lt;/P&gt;
&lt;PRE&gt;proc format;
invalue $status (upcase)
'MARRIED'='M'
'SINGLE' ='S'
'WIDOWED'='W'
'DIVORCED'='D'&lt;BR /&gt;' '= ' '&lt;BR /&gt;other=_error_
;
run;

data example;
   input status $status10.;
datalines;
Married
married
marrieD
singLE
wIDOWED
divorced&lt;BR /&gt;   &lt;BR /&gt;newvalue
;
&lt;/PRE&gt;
&lt;P&gt;Optionally use this to assign a NUMERIC code value so you have a pretty constant order and use another custom format to display the meaning of the code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This type of informat can also be used to recode values into either a new variable or (dangerous) the same.&lt;/P&gt;
&lt;PRE&gt;codedstatus = input(status,$status.);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 17:13:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894115#M353205</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-09-13T17:13:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a character format that is not case sensitive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894121#M353207</link>
      <description>&lt;P&gt;Here is another option if you don't mind creating a new variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input string $;
cards;
married
Married
MARRIED
;
run;

proc format;
 value $stat "MARRIED"='M';
run;

data test;
set test;
string1=put(upcase(string),$stat.);
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Sep 2023 17:06:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894121#M353207</guid>
      <dc:creator>Kathryn_SAS</dc:creator>
      <dc:date>2023-09-13T17:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a character format that is not case sensitive</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894191#M353216</link>
      <description>&lt;P&gt;Why not just read the data using the $UPCASE informat.&amp;nbsp; Then the stored value will be consistent and it will be easier to create a format to display the values.&amp;nbsp; If those are the only values you could use $1. as the format to display just the first letter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want more control make a custom informat and/or a custom format.&amp;nbsp; I custom informat could use the UPCASE option to convert the source to upcase in addition to encoding the values.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 23:36:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Creating-a-character-format-that-is-not-case-sensitive/m-p/894191#M353216</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-09-13T23:36:34Z</dc:date>
    </item>
  </channel>
</rss>

