<?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: remove blanks for a call symput in order to import values into memory in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346096#M79751</link>
    <description>&lt;P&gt;I cannot figure out what your question is. &amp;nbsp;Can you post example data that recreates the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS character variables are fixed length and padded with spaces. &amp;nbsp;So if you create a variable of length $5 and store 'ABDC' into then the fifth position will be a blank. &amp;nbsp;When comparing variables SAS will automatically ignore the trailing spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you want to generate macro variables that do not include the trailing spaces&amp;nbsp;then use the CALL SYMPUTX() function instead of the older CALL SYMPUT() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;138  data _null_;
139    length x $8 ;
140    x='ABCD';
141    call symput('one',x);
142    call symputx('two',x);
143  run;

NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


144  %put ONE=|&amp;amp;one| TWO=|&amp;amp;two|;
ONE=|ABCD    | TWO=|ABCD|
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 Mar 2017 11:54:13 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-03-31T11:54:13Z</dc:date>
    <item>
      <title>remove blanks for a call symput in order to import values into memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346094#M79749</link>
      <description>&lt;P&gt;I would like to apply a macro to generate different bbdd, one for each value of my_var.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I correclty import into memory the values with 5 digits, but I cannot remove the blank after the strings with four digits such as 9916, so I will see "9916 ", instead of "9916".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This cause me probles in a following code (not posted) where I want to match the values of my_var with the one of another dataset&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data my_var; &lt;BR /&gt;input my_var $5.;&lt;BR /&gt;cards;&lt;BR /&gt;27016&lt;BR /&gt;27015&lt;BR /&gt;27014&lt;BR /&gt;27011&lt;BR /&gt;27013&lt;BR /&gt;9916&lt;BR /&gt;9917&lt;BR /&gt;9909&lt;BR /&gt;9908&lt;BR /&gt;9910&lt;BR /&gt;9904&lt;BR /&gt;9905&lt;BR /&gt;9911&lt;BR /&gt;9912&lt;BR /&gt;9936&lt;BR /&gt;9935&lt;BR /&gt;9937&lt;BR /&gt;9939&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data my_var; set my_var;my_var=compbl(my_var);run;&lt;/P&gt;
&lt;P&gt;data my_var; set my_var;my_var=compress(my_var," ","");run;&lt;/P&gt;
&lt;P&gt;data my_var; set my_var;my_var=tranwrd(my_var," ","");run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;* Generate List of Possible Values;&lt;BR /&gt;proc freq data = my_var noprint;&lt;BR /&gt;table my_var/ out = bbdd;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*********************************************************************;&lt;BR /&gt;* Import Values Into Memory;&lt;BR /&gt;data _null_;&lt;BR /&gt;set bbdd end=last;&lt;BR /&gt;call symput('memory' || trim(left(_n_)), my_var);&lt;BR /&gt;if last then call symput('Nummemory', _n_);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%put Total Number of memory Variables: &amp;amp;Nummemory;&lt;BR /&gt;%put memory Variables: &amp;amp;memory1&lt;BR /&gt;&amp;amp;memory2&lt;BR /&gt;&amp;amp;memory3&lt;BR /&gt;&amp;amp;memory4&lt;BR /&gt;&amp;amp;memory5&lt;BR /&gt;&amp;amp;memory6&lt;BR /&gt;&amp;amp;memory7&lt;BR /&gt;&amp;amp;memory8&lt;BR /&gt;&amp;amp;memory9&lt;BR /&gt;&amp;amp;memory10&lt;BR /&gt;&amp;amp;memory11&lt;BR /&gt;&amp;amp;memory12&lt;BR /&gt;&amp;amp;memory13&lt;BR /&gt;&amp;amp;memory14&lt;BR /&gt;&amp;amp;memory15&lt;BR /&gt;&amp;amp;memory16&lt;BR /&gt;&amp;amp;memory17&lt;BR /&gt;&amp;amp;memory18&lt;BR /&gt;;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;*target is a big dataset, I want to create subset, using a "where", according to the values imported in memory&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data target; &lt;BR /&gt;input my_var $5.;&lt;BR /&gt;cards;&lt;BR /&gt;27016&lt;BR /&gt;27015&lt;BR /&gt;27014&lt;BR /&gt;27011&lt;BR /&gt;27013&lt;BR /&gt;9916&lt;BR /&gt;9917&lt;BR /&gt;9909&lt;BR /&gt;9908&lt;BR /&gt;9910&lt;BR /&gt;9904&lt;BR /&gt;9905&lt;BR /&gt;9911&lt;BR /&gt;9912&lt;BR /&gt;9936&lt;BR /&gt;9935&lt;BR /&gt;9937&lt;BR /&gt;9939&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%let intro=p_;&lt;/P&gt;
&lt;P&gt;option mtrace mprint;&lt;BR /&gt;%macro Creatememory;&lt;BR /&gt;%do i = 1 %to &amp;amp;Nummemory;&lt;BR /&gt;data &amp;amp;intro&amp;amp;&amp;amp;memory&amp;amp;i;&lt;BR /&gt;set target;where (my_var = "&amp;amp;&amp;amp;memory&amp;amp;i");&lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend Creatememory;&lt;BR /&gt;%Creatememory;&lt;BR /&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;
&lt;P&gt;Thanks in advance&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 12:04:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346094#M79749</guid>
      <dc:creator>progster</dc:creator>
      <dc:date>2017-03-31T12:04:02Z</dc:date>
    </item>
    <item>
      <title>Re: remove blanks for a call symput in order to import values into memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346096#M79751</link>
      <description>&lt;P&gt;I cannot figure out what your question is. &amp;nbsp;Can you post example data that recreates the problem?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS character variables are fixed length and padded with spaces. &amp;nbsp;So if you create a variable of length $5 and store 'ABDC' into then the fifth position will be a blank. &amp;nbsp;When comparing variables SAS will automatically ignore the trailing spaces.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that if you want to generate macro variables that do not include the trailing spaces&amp;nbsp;then use the CALL SYMPUTX() function instead of the older CALL SYMPUT() function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;138  data _null_;
139    length x $8 ;
140    x='ABCD';
141    call symput('one',x);
142    call symputx('two',x);
143  run;

NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


144  %put ONE=|&amp;amp;one| TWO=|&amp;amp;two|;
ONE=|ABCD    | TWO=|ABCD|
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Mar 2017 11:54:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346096#M79751</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-31T11:54:13Z</dc:date>
    </item>
    <item>
      <title>Re: remove blanks for a call symput in order to import values into memory</title>
      <link>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346102#M79754</link>
      <description>&lt;P&gt;I used symputx and it works, thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 31 Mar 2017 12:09:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/remove-blanks-for-a-call-symput-in-order-to-import-values-into/m-p/346102#M79754</guid>
      <dc:creator>progster</dc:creator>
      <dc:date>2017-03-31T12:09:40Z</dc:date>
    </item>
  </channel>
</rss>

