<?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 don't PROC SQL and Data Step create same Macro Variable in this case? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129228#M26370</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or using&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select distinct trim(name) into :parm_num2 &lt;STRONG&gt;separated by ' '&lt;/STRONG&gt;&amp;nbsp; from _cont_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 09 Jul 2013 14:06:23 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2013-07-09T14:06:23Z</dc:date>
    <item>
      <title>Why don't PROC SQL and Data Step create same Macro Variable in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129226#M26368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have the outputs of PROC CONTENTS, and I am trying to create a macro variable of something in the NAME column of the PROC CONTENTS output. I try this via a DATA step, and also via PROC SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The following code, working on the same data set, should produce two macro variables with the exact same values (in my opinion), but it does not. There are extra blanks appended to the second macro variable. Why? How can I fix this so PROC SQL produces a macro variable without the extra blanks?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set _cont_(where=(upcase(name)='PARAM_NUM' or upcase(name)='PARM_NUM'));&lt;/P&gt;&lt;P&gt;&amp;nbsp; call symputx('parm_num1',name);&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt; proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp; select distinct trim(name) into :parm_num2 from _cont_ where upcase(name) eqt 'PARAM_NUM' or upcase(name) eqt 'PARM_NUM';&lt;/P&gt;&lt;P&gt; quit;&lt;/P&gt;&lt;P&gt; %put PARM_NUM1 &amp;amp;parm_num1 ****;&lt;/P&gt;&lt;P&gt; %put PARM_NUM2 &amp;amp;parm_num2 ****;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results I get from the PUT statements show the values are different with PARM_NUM2 appearing to have extra blanks:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1110&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put PARM_NUM1 &amp;amp;parm_num1 ****;&lt;/P&gt;&lt;P&gt;PARM_NUM1 parm_num ****&lt;/P&gt;&lt;P&gt;1111&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %put PARM_NUM2 &amp;amp;parm_num2 ****;&lt;/P&gt;&lt;P&gt;PARM_NUM2 parm_num&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ****&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 13:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129226#M26368</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-07-09T13:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't PROC SQL and Data Step create same Macro Variable in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129227#M26369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use TRIMMED option&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;17&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc sql;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;18&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name into :name1 from sashelp.class(obs=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;19&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: name1=*&amp;amp;name1*;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: name1=*Alfred&amp;nbsp; *&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;20&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select name into :name2 trimmed from sashelp.class(obs=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;21&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; NOTE: name2=*&amp;amp;name2*;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;NOTE: name2=*Alfred*&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;22&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; quit;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 13:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129227#M26369</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2013-07-09T13:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't PROC SQL and Data Step create same Macro Variable in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129228#M26370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;or using&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;select distinct trim(name) into :parm_num2 &lt;STRONG&gt;separated by ' '&lt;/STRONG&gt;&amp;nbsp; from _cont_&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Jul 2013 14:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129228#M26370</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2013-07-09T14:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't PROC SQL and Data Step create same Macro Variable in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129229#M26371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;Hi,&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;By Default, CALL SYMPUT will maintain any leading or trailling blanks...In below example program, i have created name which have 20 bytes length but originally there is only 3 bytes so name will have 17 extra trailling blanks which is going to retain while creating macro variable by using CALL SYMPUT during data step execution...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;But if you use CALL SYMPUTX insted of CALL SYMPUT then it will remove any leading or trailling blanks from the variable...Here, CALL SYMPUT "X" represents EXTRA BLANKS to be remove and in contrast, PROC SQL will retain any leading or trailing blanks while creating macro variable during proc sql execution...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;SEE THE BELOW EXAMPLE PROGRAME...HOPE IT HELPS...&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; name &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: teal;"&gt;$20.&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;&amp;nbsp; name = &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;"XYZ"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; symputx(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;"data_X_name"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;,name);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;call&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; symput(&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: purple;"&gt;"data_name"&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;,name);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; name &lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; :sql_name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-family: 'Courier New';"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; CALL SYMPUT will resolve to: &amp;amp;data_name.*****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; CALL SYMPUTX will resolve to: &amp;amp;data_x_name.*****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: blue;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt; PROC SQL will resolve to: &amp;amp;sql_name.*****;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New'; background: white; color: black;"&gt;-Urvish&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 04:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129229#M26371</guid>
      <dc:creator>UrvishShah</dc:creator>
      <dc:date>2013-07-10T04:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Why don't PROC SQL and Data Step create same Macro Variable in this case?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129230#M26372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great stuff, guys, thank you very much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 12:16:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Why-don-t-PROC-SQL-and-Data-Step-create-same-Macro-Variable-in/m-p/129230#M26372</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2013-07-10T12:16:08Z</dc:date>
    </item>
  </channel>
</rss>

