<?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 Adding quotes to string variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914292#M360260</link>
    <description>&lt;P&gt;I am trying to add quotes to my string variable but my QUOTE function is not lighting up blue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;code3 = quote(code2);&lt;BR /&gt;put code3=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code2 variable contains string ICD codes.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 02 Feb 2024 19:46:54 GMT</pubDate>
    <dc:creator>Tithi</dc:creator>
    <dc:date>2024-02-02T19:46:54Z</dc:date>
    <item>
      <title>Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914292#M360260</link>
      <description>&lt;P&gt;I am trying to add quotes to my string variable but my QUOTE function is not lighting up blue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;&lt;P&gt;code3 = quote(code2);&lt;BR /&gt;put code3=;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my code2 variable contains string ICD codes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 19:46:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914292#M360260</guid>
      <dc:creator>Tithi</dc:creator>
      <dc:date>2024-02-02T19:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914301#M360265</link>
      <description>&lt;P&gt;When you run:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input code2 $;
cards;
ABC
AB
A
;
run;

data want;
  set have;
  code3 = quote(code2);
  put code3=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you will get:&lt;/P&gt;
&lt;PRE&gt;code3="ABC     "
code3="AB      "
code3="A       "
NOTE: There were 3 observations read from the data set WORK.HAVE.
NOTE: The data set WORK.WANT has 3 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/PRE&gt;
&lt;P&gt;in the log.&lt;/P&gt;
&lt;P&gt;If you don't want spaces at the end, use STRIP() function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  code3 = quote(STRIP(code2));
  put code3=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and you will get:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;code3="ABC"
code3="AB"
code3="A"&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;in the log.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 20:22:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914301#M360265</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-02T20:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914305#M360266</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326203"&gt;@Tithi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to add quotes to my string variable but my QUOTE function is not lighting up blue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;
&lt;P&gt;code3 = quote(code2);&lt;BR /&gt;put code3=;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my code2 variable contains string ICD codes.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;A very large number of functions do not get highlighted. It can depend on your version of SAS, OS and if you are using the Display Manager (or "Base" SAS ) you can add custom highlights.&lt;/P&gt;
&lt;P&gt;Best practice is to assign a length to new character variables. You can end up with odd truncated values because the first assignment can set the length, such as in your Code3= , of the variable and lead to odd results.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 20:27:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914305#M360266</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-02T20:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914317#M360270</link>
      <description>&lt;P&gt;I added the length statement but for some reason but QUOTE function is still not working.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 20:44:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914317#M360270</guid>
      <dc:creator>Tithi</dc:creator>
      <dc:date>2024-02-02T20:44:24Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914323#M360273</link>
      <description>&lt;P&gt;Show us the log...&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 21:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914323#M360273</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-02-02T21:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914326#M360274</link>
      <description>&lt;P&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;code3=&lt;BR /&gt;NOTE: There were 73217 observations read from the data set WORK.ICDGROUP2.&lt;BR /&gt;NOTE: The data set WORK.ICDGROUP3 has 73217 observations and 8 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 20.25 seconds&lt;BR /&gt;cpu time 7.82 seconds&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 21:29:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914326#M360274</guid>
      <dc:creator>Tithi</dc:creator>
      <dc:date>2024-02-02T21:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914331#M360277</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you don't want spaces at the end, use STRIP() function:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;If you don't want spaces at the end use the &lt;STRONG&gt;TRIM()&lt;/STRONG&gt; function. The STRIP() function will also remove spaces from the beginning.&amp;nbsp; Trailing spaces are not normally significant to SAS strings comparisons, but leading spaces are.&amp;nbsp; &lt;STRONG&gt;Removing the leading spaces makes a significant change to the value&lt;/STRONG&gt; being represented while removing just the trailing spaces does not.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 21:49:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914331#M360277</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T21:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914340#M360280</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/326203"&gt;@Tithi&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am trying to add quotes to my string variable but my QUOTE function is not lighting up blue.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My code here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;set have;&lt;/P&gt;
&lt;P&gt;code3 = quote(code2);&lt;BR /&gt;put code3=;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;my code2 variable contains string ICD codes.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is your question really just about&lt;STRONG&gt; what &lt;FONT color="#FF0000"&gt;colors&lt;/FONT&gt; the &lt;FONT color="#0000FF"&gt;text editor&lt;/FONT&gt; is using&lt;/STRONG&gt; to display your program?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do not worry too much about what the text editor is doing.&amp;nbsp; The important thing is whether your code WORKS or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code is valid.&amp;nbsp; It will work as long as CODE3 is defined long enough to hold the longest values of CODE2 after it has add quotes added around it (and any embedded quotes doubled).&amp;nbsp; Since you did not define CODE3 before the assignment statement SAS will default to defining it to have a length of 200 bytes.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 21:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914340#M360280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-02T21:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding quotes to string variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914341#M360281</link>
      <description>&lt;P&gt;Interesting. You need to post the complete log containing the code that ran, actually.&lt;/P&gt;
&lt;P&gt;Why do you want to include quotes in the values?&lt;/P&gt;</description>
      <pubDate>Fri, 02 Feb 2024 21:58:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Adding-quotes-to-string-variable/m-p/914341#M360281</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2024-02-02T21:58:08Z</dc:date>
    </item>
  </channel>
</rss>

