<?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: Why trim/strip/compress statements don't work for my data when removing trailing space after tex in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665586#M199043</link>
    <description>&lt;P&gt;Show us the code you have tried, by pasting your code into the box that appears when you click on the "running man" icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us a portion of your data as SAS data step code.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
    <pubDate>Sun, 28 Jun 2020 01:00:30 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-06-28T01:00:30Z</dc:date>
    <item>
      <title>Why trim/strip/compress statements don't work for my data when removing trailing space after text?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665582#M199041</link>
      <description>&lt;P&gt;Hi SAS Pros,&lt;/P&gt;
&lt;P&gt;I am facing a QUESTION!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am doing an almost entire character dataset. I found some texts with space after it. Specifically, I want to remove all the trailing space after text. I don't care about the leading space or the extra space in between. I have tried trim(var name), trimn(var name), strip(var name), and compress(var name). But none of them worked for my data. I don't why it doesn't.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, I am curious that why SAS cannot recognize the text with a trailing space, e.g. Egg; bread; carrot; and Egg; bread; carrot;&amp;nbsp; (there is a trailing space after). I found the texts with trailing spaces were not successfully coded.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you so much for any help!&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;C&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 00:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665582#M199041</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-06-28T00:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665586#M199043</link>
      <description>&lt;P&gt;Show us the code you have tried, by pasting your code into the box that appears when you click on the "running man" icon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Show us a portion of your data as SAS data step code.&lt;/P&gt;
&lt;DIV id="tap-translate"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sun, 28 Jun 2020 01:00:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665586#M199043</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-06-28T01:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665587#M199044</link>
      <description>&lt;P&gt;I believe you're looking for compbl(). Solution approach to "clean-up" your data &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-with-this-case/m-p/665589#M199046" target="_self"&gt;here&lt;/A&gt; where you're asking the same question but give us more information.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 01:52:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665587#M199044</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-28T01:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665598#M199053</link>
      <description>&lt;P&gt;I may misunderstand how SAS stores strings.&lt;/P&gt;
&lt;P&gt;SAS stores fixed-length character strings. If the string is shorter than the variable, its value is padded with trailing spaces. For this reason, when comparing values, SAS omits trailing spaces, thus 'A' is equal to 'A&amp;nbsp; '.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 02:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665598#M199053</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-28T02:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665602#M199055</link>
      <description>Your strings actually had leading spaces not trailing if you're referring to your previous question. You can see them by printing out your values using a hex format and seeing a 20 as the first digits which is the hex code for a space. &lt;BR /&gt;&lt;BR /&gt;proc freq data=have;&lt;BR /&gt;table item;&lt;BR /&gt;format item $hex32.;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 28 Jun 2020 03:32:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665602#M199055</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-28T03:32:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665603#M199056</link>
      <description>&lt;P&gt;Your question is not at all clear.&amp;nbsp; You posted this in you quesiton:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Egg; bread; carrot; 
and 
Egg; bread; carrot;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Both of those two strings separated by AND look exactly the same as you can tell when posted using a monospaced font.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 03:32:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665603#M199056</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-28T03:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665606#M199058</link>
      <description>&lt;P&gt;See Maxim 46.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 03:39:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665606#M199058</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-06-28T03:39:20Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665649#M199072</link>
      <description>&lt;P&gt;And problems like this are exactly why I suggested making a "long" set with single values and no delimiters. If your data source is so inconsistent then it really is up to you make it consistent. Or browbeat the source to fix the problems at the source.&lt;/P&gt;
&lt;P&gt;I suspect it will be much easier to clean the data to a consistent behavior than the code around all of the garbage in long inconsistently delimited strings.&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 17:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665649#M199072</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-28T17:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665652#M199074</link>
      <description>&lt;P&gt;Thank you Paige and all of you who responded me with this thread!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think we won't know what the exact issue it is until we see the portion of the data. Enclosed is the portion of the variable with trailing space from what I understand. Actually, it could be leading spaces or tab or return/enter or whatever. You can see from the Excel file that I uploaded. If you find there are two 'identical'&amp;nbsp;values, there must be one without a trailing space and&amp;nbsp;one with it, such as 'Atrial Fibrillation' and 'Atrial Fibrillation '. When I created dummy variable, SAS can only recognize the first 'Atrial Fibrillation'---the one without the trailing space after text. Same issues happened with 'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema&amp;nbsp;'. Because the variable doesn't have the value of this one without the trailing space, it only showed up once, but it still has a trailing space that I want to remove.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I have used the following syntax to generate the dummies, but realized that SAS doesn't recognize those ones with trailing&amp;nbsp;spaces:&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; have;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; significant_conditions in &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Atrial Fibrillation'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Atrial Fibrillation '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly '&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Atherosclerotic and Hypertensive Cardiovascular Disease&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Atherosclerotic and Hypertensive Cardiovascular Disease'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; heart_disease=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; significant_conditions in &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Alcoholism=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; significant_conditions in &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; obesity=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; significant_conditions in &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt; (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Chronic Alcoholism; Atherosclerotic and Hypertensive Cardiovascular Disease; Emphysema&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'Cardiomegaly; Arteriosclerotic Cardiovascular Disease; Morbid Obesity&amp;nbsp;'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; respiratory_disease=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="4"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 19:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665652#M199074</guid>
      <dc:creator>CynthiaWei</dc:creator>
      <dc:date>2020-06-28T19:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665660#M199075</link>
      <description>&lt;P&gt;&lt;SPAN&gt;If you really need to test if 'XXX' is different than 'XXX&amp;nbsp; &amp;nbsp; &amp;nbsp;' then you will probably need to change the spaces to some other character and then test.&amp;nbsp; But I cannot think of any real situation where that would be needed, and your example program does not need it.&amp;nbsp;&lt;/SPAN&gt;In your current code you are repeating the same string to test in the IN list. Having the same string twice in the list does not make the result of the IN operator any different. Prove it to yourself by writing a simple test program.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
  input string $20.;
cards;
xxx
abc
;

data want;
  set have;
   test1 = string  in ('xxx');
   test2 = string in ('xxx     ');
   test3 = string in ('xxx                 ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Results:&lt;/P&gt;
&lt;PRE&gt;Obs    string    test1    test2    test3

 1      xxx        1        1        1
 2      abc        0        0        0
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Please show some actual data for the variable&amp;nbsp;&lt;STRONG&gt;significant_conditions&amp;nbsp;&lt;/STRONG&gt;in the dataset &lt;STRONG&gt;have&lt;/STRONG&gt; and what result you want out.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jun 2020 20:57:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665660#M199075</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-06-28T20:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: Why trim/strip/compress statements don't work for my data when removing trailing space after tex</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665668#M199076</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/266374"&gt;@CynthiaWei&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Repeating the code I've already posted &lt;A href="https://communities.sas.com/t5/SAS-Programming/How-to-create-dummy-variables-with-this-case/m-p/665589#M199046" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;to answer your question. This code will also work for your medical data - and it will clean-up your strings by replacing any combination of characters that are not a letter, number, underscore or dash with a blank.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover dlm='|';
  input id lunch :$100.;
  datalines4;
1|egg; bread; carrot;
2|cheese;	veggie juice; cucumber;
3|noodles; three pieces	of pork ribs; lettuce 
4|some bread   stick; salmon; mango juice
5|milk; cookie; tomato;	
6|bread; carrot; egg;
;;;;

data have_long(drop=_:);
  length id 8;
  set have(rename=(id=group_id));
  length item $60;
  do _i=1 by 1;
    item=scan(lunch,_i,';');
    item=prxchange('s/[^\w-]+/ /',-1,strip(item));
    item=upcase(strip(item));
    if missing(item) then leave;
    id+1;
    output;
  end;
run;

proc format;
  value $foodcat (multilabel)
    'BREAD' = 'Carbon'
    'CARROT' = 'Fiber'
    'CHEESE' = 'Protein'
    'COOKIE' = 'Carbon'
    'CUCUMBER' = 'Fiber'
    'EGG' = 'Protein'
    'LETTUCE' = 'Fiber'
    'MANGO JUICE' = 'Fiber'
    'MANGO JUICE' = 'Juice'
    'MILK' = 'Protein'
    'NOODLES' = 'Carbon'
    'SALMON' = 'Protein'
    'SOME BREAD STICK' = 'Carbon'
    'THREE PIECES OF PORK RIBS' = 'Protein'
    'TOMATO' = 'Fiber'
    'VEGGIE JUICE' = 'Fiber'
    'VEGGIE JUICE' = 'Juice'
    ;
run;

proc summary data=have_long n nway;
  class group_id;
  class item / mlf;
  id lunch;
  format item $foodcat.;
  output out=long_n;
run; 

proc transpose data=long_n out=want(drop=_:) ;
  by group_id lunch;
  id item;
  var _freq_;
run;

proc print data=want;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1593385631457.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/46746i1FF1E3DE6A7D114C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1593385631457.png" alt="Patrick_0-1593385631457.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Just create a list of distinct terms from the have_long table and then use this list to replace the format in above code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The &lt;EM&gt;multilabel&lt;/EM&gt; option in the format allows you to assign more than one category to a single term. The category names become the SAS variable names when transposing the data so make sure to use strings that are valid to use as SAS variable names.&lt;SPAN style="font-family: inherit;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  select distinct item
  from have_long;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jun 2020 00:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-trim-strip-compress-statements-don-t-work-for-my-data-when/m-p/665668#M199076</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-06-29T00:43:41Z</dc:date>
    </item>
  </channel>
</rss>

