<?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: Apostrophes in assignment statements in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74343#M21534</link>
    <description>could be the macro causing the problem, if this (Don't Know) is the only time you use/generate double quotes.&lt;BR /&gt;
&lt;BR /&gt;
better evidence would help diagnosis.&lt;BR /&gt;
How about providing a SAS log snippet with symbolgen, mprint and mlogic.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
    <pubDate>Tue, 17 Feb 2009 19:38:15 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-02-17T19:38:15Z</dc:date>
    <item>
      <title>Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74340#M21531</link>
      <description>I'm doing something like&lt;BR /&gt;
&lt;BR /&gt;
if x = 'abc' then y = 1;&lt;BR /&gt;
&lt;BR /&gt;
But one of the things I'm checking for has an apostrophe in it.  So it is&lt;BR /&gt;
&lt;BR /&gt;
if x = 'Don't Know' then y=1;&lt;BR /&gt;
&lt;BR /&gt;
But of course I can't do that because that gives me unbalanced quotes.  So instead i tried&lt;BR /&gt;
&lt;BR /&gt;
if x = "Don't Know" then y=1;&lt;BR /&gt;
&lt;BR /&gt;
I don't get unbalanced quotes or an error when I use that, but the condition x="Don't Know" is never satisfied (even though it should be sometimes) and therefore I never get y=1 assigned. &lt;BR /&gt;
&lt;BR /&gt;
Any ideas on what code to use so that I do get y=1 assigned when x is Don't Know?</description>
      <pubDate>Tue, 17 Feb 2009 17:52:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74340#M21531</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2009-02-17T17:52:26Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74341#M21532</link>
      <description>Without seeing your data that it is checking, there is no way to tell what the cause could be. Your last statement is syntactically correct.&lt;BR /&gt;
&lt;BR /&gt;
But here's a guess anyway.&lt;BR /&gt;
&lt;BR /&gt;
Use trim(x) instead of x to eliminate trailing blanks from causing the assignment statement to fail.

Message was edited by: Paige</description>
      <pubDate>Tue, 17 Feb 2009 18:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74341#M21532</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2009-02-17T18:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74342#M21533</link>
      <description>Here is the exact code.  It is part of a macro but that shouldn't matter, especially since I have other similiar macros that work fine.  And the code below works fine too except for the line with Don't Know" in it.  (Yes, it's stupid to have to do this task in the first place, but it's a long story as to why I have to.) &lt;BR /&gt;
&lt;BR /&gt;
data x;&lt;BR /&gt;
 set final;    &lt;BR /&gt;
&lt;BR /&gt;
  if &amp;amp;VAR = 'Strongly Agree'    then &amp;amp;VAR = '1_' || 'Strongly Agree'   ;      &lt;BR /&gt;
  if &amp;amp;VAR = 'Agree'             then &amp;amp;VAR = '2_' || 'Agree'            ;      &lt;BR /&gt;
  if &amp;amp;VAR = 'Disagree'          then &amp;amp;VAR = '3_' || 'Disagree'         ;      &lt;BR /&gt;
  if &amp;amp;VAR = 'Strongly Disagree' then &amp;amp;VAR = '4_' || 'Strongly Disagree';      &lt;BR /&gt;
  if &amp;amp;VAR = "Don't Know"        then &amp;amp;VAR = '5_' || "Don't Know"       ;      &lt;BR /&gt;
  if &amp;amp;VAR = 'No answer'         then &amp;amp;VAR = '6_' || 'No answer'        ;      &lt;BR /&gt;
&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 17 Feb 2009 18:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74342#M21533</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2009-02-17T18:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74343#M21534</link>
      <description>could be the macro causing the problem, if this (Don't Know) is the only time you use/generate double quotes.&lt;BR /&gt;
&lt;BR /&gt;
better evidence would help diagnosis.&lt;BR /&gt;
How about providing a SAS log snippet with symbolgen, mprint and mlogic.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 17 Feb 2009 19:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74343#M21534</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-17T19:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74344#M21535</link>
      <description>Here is the macro and the log results for it when using mlogic, etc.&lt;BR /&gt;
&lt;BR /&gt;
1265  %MACRO VAL_SA_A_D_SD_DK_No_a (var);&lt;BR /&gt;
1266  data x;&lt;BR /&gt;
1267     set final;&lt;BR /&gt;
1268     if &amp;amp;VAR = 'Strongly Agree'    then &amp;amp;VAR = '1_' || 'Strongly Agree'   ;&lt;BR /&gt;
1269     if &amp;amp;VAR = 'Agree'             then &amp;amp;VAR = '2_' || 'Agree'            ;&lt;BR /&gt;
1270     if &amp;amp;VAR = 'Disagree'          then &amp;amp;VAR = '3_' || 'Disagree'         ;&lt;BR /&gt;
1271     if &amp;amp;VAR = 'Strongly Disagree' then &amp;amp;VAR = '4_' || 'Strongly Disagree';&lt;BR /&gt;
1272     if &amp;amp;VAR = "Don't Know"        then &amp;amp;VAR = '5_' || "Don't Know"       ;&lt;BR /&gt;
1273     if &amp;amp;VAR = 'No answer'         then &amp;amp;VAR = '6_' || 'No answer'        ;&lt;BR /&gt;
1274  run;&lt;BR /&gt;
1275  proc freq data=final;   tables &amp;amp;VAR;   run;&lt;BR /&gt;
1276  proc freq data=x    ;   tables &amp;amp;VAR;   run;&lt;BR /&gt;
1277  %MEND  VAL_SA_A_D_SD_DK_No_a;&lt;BR /&gt;
1278  %VAL_SA_A_D_SD_DK_No_a   (S1_D1 );&lt;BR /&gt;
MLOGIC(VAL_SA_A_D_SD_DK_NO_A):  Beginning execution.&lt;BR /&gt;
MLOGIC(VAL_SA_A_D_SD_DK_NO_A):  Parameter VAR has value S1_D1&lt;BR /&gt;
WARNING: The Base Product product with which DATASTEP is associated will be expiring soon, and is currently in warning mode to&lt;BR /&gt;
         indicate this upcoming expiration. Most typically this warning period runs for 45 days. Please run PROC SETINIT to&lt;BR /&gt;
         obtain more information on your warning period.&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   data x;&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   set final;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = 'Strongly Agree' then S1_D1 = '1_' || 'Strongly Agree' ;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = 'Agree' then S1_D1 = '2_' || 'Agree' ;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = 'Disagree' then S1_D1 = '3_' || 'Disagree' ;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = 'Strongly Disagree' then S1_D1 = '4_' || 'Strongly Disagree';&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = "Don't Know" then S1_D1 = '5_' || "Don't Know" ;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   if S1_D1 = 'No answer' then S1_D1 = '6_' || 'No answer' ;&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 115 observations read from the data set WORK.FINAL.&lt;BR /&gt;
NOTE: The data set WORK.X has 115 observations and 107 variables.&lt;BR /&gt;
NOTE: DATA statement used (Total process time):&lt;BR /&gt;
      real time           0.03 seconds&lt;BR /&gt;
      cpu time            0.03 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
WARNING: The Base Product product with which FREQ is associated will be expiring soon, and is currently in warning mode to&lt;BR /&gt;
         indicate this upcoming expiration. Most typically this warning period runs for 45 days. Please run PROC SETINIT to&lt;BR /&gt;
         obtain more information on your warning period.&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   proc freq data=final;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   tables S1_D1;&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 115 observations read from the data set WORK.FINAL.&lt;BR /&gt;
NOTE: PROCEDURE FREQ used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
WARNING: The Base Product product with which FREQ is associated will be expiring soon, and is currently in warning mode to&lt;BR /&gt;
         indicate this upcoming expiration. Most typically this warning period runs for 45 days. Please run PROC SETINIT to&lt;BR /&gt;
         obtain more information on your warning period.&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   proc freq data=x ;&lt;BR /&gt;
SYMBOLGEN:  Macro variable VAR resolves to S1_D1&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   tables S1_D1;&lt;BR /&gt;
MPRINT(VAL_SA_A_D_SD_DK_NO_A):   run;&lt;BR /&gt;
&lt;BR /&gt;
NOTE: There were 115 observations read from the data set WORK.X.&lt;BR /&gt;
NOTE: PROCEDURE FREQ used (Total process time):&lt;BR /&gt;
      real time           0.01 seconds&lt;BR /&gt;
      cpu time            0.01 seconds&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
MLOGIC(VAL_SA_A_D_SD_DK_NO_A):  Ending execution.&lt;BR /&gt;
&lt;BR /&gt;
And here is the generated output.  The prefix numbers get assigned for all the other groups but not for the Don't Know group.&lt;BR /&gt;
&lt;BR /&gt;
                                                Cumulative    Cumulative&lt;BR /&gt;
S1_D1                  Frequency     Percent     Frequency      Percent&lt;BR /&gt;
ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ&lt;BR /&gt;
1_Strongly Agree             23       20.91            23        20.91&lt;BR /&gt;
2_Agree                      31       28.18            54        49.09&lt;BR /&gt;
3_Disagree                   23       20.91            77        70.00&lt;BR /&gt;
4_Strongly Disagree           4        3.64            81        73.64&lt;BR /&gt;
Don’t Know                   29       26.36           110       100.00&lt;BR /&gt;
&lt;BR /&gt;
                          Frequency Missing = 5</description>
      <pubDate>Tue, 17 Feb 2009 20:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74344#M21535</guid>
      <dc:creator>n6</dc:creator>
      <dc:date>2009-02-17T20:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74345#M21536</link>
      <description>Based on what you provided thus far, I could not recreate the problem, with a SAS 9.1.3 SP4 environment on Windows, with a manually assigned S1_D1 initial value in a RETAIN statement.&lt;BR /&gt;
&lt;BR /&gt;
You have an interesting challenge - continue to presume that there is something in your data or code.  Suggest you add some PUTLOG _ALL_;  statements before and then again after the re-assignment statements.  Also, consider using ELSE "condition" tests so that only one statement test will pass, if any.  Appears as though you will need to diagnose the problem further within your DATA step -- as suggested with adding PUTLOG statements along the way, at various code points.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 18 Feb 2009 02:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74345#M21536</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-02-18T02:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Apostrophes in assignment statements</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74346#M21537</link>
      <description>You may want to use the RANK function to examine the apostrophe to make sure it is exactly the same character.  Otherwise split the word and check for the substring before and after the apostrophe.

Message was edited by: Flip</description>
      <pubDate>Wed, 18 Feb 2009 12:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Apostrophes-in-assignment-statements/m-p/74346#M21537</guid>
      <dc:creator>Flip</dc:creator>
      <dc:date>2009-02-18T12:47:10Z</dc:date>
    </item>
  </channel>
</rss>

