<?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: Problem name table with float numbers in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679963#M205404</link>
    <description>&lt;P&gt;&amp;amp;amp; is a HTML code for the ampersand; it was inserted because code was not posted into a code window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;Please do ALWAYS(!) use the "little running man" button (right next to the one indicated):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/8D8B612AA6AB1DC7E9A0812281D56E02/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;for posting code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess that the code snippets should be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro macro2(v, threshold);
proc sql; create table_&amp;amp;threshold
....
%mend;

%macro table_result(V,threshold);
%DO i=1 %TO &amp;amp;threshold %BY 0.5;
%macro2(&amp;amp;V,&amp;amp;i);
%END;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which would, of course, create invalid dataset names. Since we have no idea what the V parameter in macro2 is doing, there's no way to know what is actually the goal of this construct, and how to do it better (and syntactically correct).&lt;/P&gt;
&lt;P&gt;To replace dots with underlines, one can use the TRANSLATE function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro table_result(vthreshold);
%do i = 1 %to &amp;amp;threshold. %by 0.5;
  %let i_corr = %sysfunc(translate(&amp;amp;i.,_,.));
  %macro2(&amp;amp;v.,&amp;amp;i_corr.);
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Aug 2020 06:40:28 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-28T06:40:28Z</dc:date>
    <item>
      <title>Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679950#M205392</link>
      <description>Hello&lt;BR /&gt;I created a macro which has a threshold parameter and which generates a table name: table_&amp;amp;amp;threshold. then I created another macro of iterations of the first macro by threshold but my problem is when I want to use comma thresholds it does not work because the name of the table cannot contain a comma for example: table_0.5&lt;BR /&gt;I want to calculate another parameter when I Have threshold 0.5 I want to generate table_0_5&lt;BR /&gt;&lt;BR /&gt;this is part of my code:&lt;BR /&gt;&lt;BR /&gt;%macro macro2(v, threshold);&lt;BR /&gt;proc sql; create table_&amp;amp;amp;threshold&lt;BR /&gt;....&lt;BR /&gt;%mend;&lt;BR /&gt;&lt;BR /&gt;%macro table_result(V,threshold);&lt;BR /&gt;%DO i=1 %TO &amp;amp;amp;threshold %BY 0.5;&lt;BR /&gt;%macro2(&amp;amp;amp;V,&amp;amp;amp;i);&lt;BR /&gt;%END;&lt;BR /&gt;%mend;</description>
      <pubDate>Fri, 28 Aug 2020 05:39:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679950#M205392</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-08-28T05:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679954#M205396</link>
      <description>&lt;P&gt;Having data in names of datasets or variables is a bad idea in 934 of 937 cases.&lt;/P&gt;
&lt;P&gt;Maybe the problem you have could be solved by using by-group-processing, that way you don't need to write loops and you can get rid of unnecessary macro-code.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 05:38:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679954#M205396</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2020-08-28T05:38:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679955#M205397</link>
      <description>How I can use by-group-processing?&lt;BR /&gt;you can give me an exemple ?</description>
      <pubDate>Fri, 28 Aug 2020 05:44:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679955#M205397</guid>
      <dc:creator>mazouz</dc:creator>
      <dc:date>2020-08-28T05:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679959#M205401</link>
      <description>&lt;P&gt;There are errors in the code as posted:&lt;/P&gt;
&lt;P&gt;1)&amp;nbsp;Macro variable&amp;nbsp;&lt;STRONG&gt;amp&amp;nbsp;&lt;/STRONG&gt;was not assigned.&lt;/P&gt;
&lt;P&gt;2)&lt;STRONG&gt;&lt;SPAN&gt; create table_&amp;amp;amp;threshold&lt;/SPAN&gt;&lt;/STRONG&gt; - did you mean:&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;create table_&amp;amp;amp&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;._&lt;/STRONG&gt;&lt;/FONT&gt;threshold ?&lt;BR /&gt;&amp;nbsp; &amp;nbsp; (I have replaced the ';' by '._' )&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3)&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;%TO &amp;amp;amp;threshold&lt;/STRONG&gt; - same error as above ?!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;4) To convert 0.5 into 0_5 you can use next code:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let ampx = %sysfunc(translate(&amp;amp;amp,'_','.'));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then use &amp;amp;ampx to generate the table name;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 06:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679959#M205401</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-08-28T06:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679963#M205404</link>
      <description>&lt;P&gt;&amp;amp;amp; is a HTML code for the ampersand; it was inserted because code was not posted into a code window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/339736"&gt;@mazouz&lt;/a&gt;&amp;nbsp;Please do ALWAYS(!) use the "little running man" button (right next to the one indicated):&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg"&gt;&lt;img src="https://communities.sas.com/skins/images/8D8B612AA6AB1DC7E9A0812281D56E02/responsive_peak/images/image_not_found.png" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;for posting code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess that the code snippets should be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro macro2(v, threshold);
proc sql; create table_&amp;amp;threshold
....
%mend;

%macro table_result(V,threshold);
%DO i=1 %TO &amp;amp;threshold %BY 0.5;
%macro2(&amp;amp;V,&amp;amp;i);
%END;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which would, of course, create invalid dataset names. Since we have no idea what the V parameter in macro2 is doing, there's no way to know what is actually the goal of this construct, and how to do it better (and syntactically correct).&lt;/P&gt;
&lt;P&gt;To replace dots with underlines, one can use the TRANSLATE function:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro table_result(vthreshold);
%do i = 1 %to &amp;amp;threshold. %by 0.5;
  %let i_corr = %sysfunc(translate(&amp;amp;i.,_,.));
  %macro2(&amp;amp;v.,&amp;amp;i_corr.);
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Aug 2020 06:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679963#M205404</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-28T06:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679980#M205413</link>
      <description>&lt;P&gt;It's been a long time since I tested this, so I could be wrong, but ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS does not permit decimal points in the %DO loop parameters.&amp;nbsp; This in itself would be illegal:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to 5 %by 0.5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Instead, you have to use integer values only, such as:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=10 %to 50 %by 5;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To convert your original loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to &amp;amp;amp.threshold %by 0.5;
   %macro2(&amp;amp;amp.V,&amp;amp;amp.i);
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;first correct the %END value in the loop (&amp;amp;amp.threshold isn't a valid number) then you could use:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=10 %to 10*&amp;amp;amp.threshold %by 5;
   %macro2(&amp;amp;amp.V,%sysevalf(&amp;amp;i/10));
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You would still need to convert the decimal points to underscores, as others have pointed out.&amp;nbsp; It might be easier to forget about decimal points entirely.&amp;nbsp; Change the definition of %MACRO2 (adding logic to pick apart the value of &amp;amp;i to determine the data set name):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=10 %to 10*&amp;amp;amp.threshold %by 5;
   %macro2(&amp;amp;amp.V, &amp;amp;i)
%end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Aug 2020 10:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679980#M205413</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2020-08-28T10:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679998#M205421</link>
      <description>&lt;PRE&gt;%macro macro2(v, threshold);
%put &amp;amp;v &amp;amp;threshold table_%sysfunc(translate(&amp;amp;threshold,_,.));
%mend;

%macro table_result(V,threshold);
%let i=1 ;
%do %while(%sysevalf(&amp;amp;i&amp;lt;=&amp;amp;threshold));
%macro2(&amp;amp;V,&amp;amp;i);
%let i=%sysevalf(&amp;amp;i+0.5);
%END;
%mend;

%table_result(1,5)&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Aug 2020 12:10:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/679998#M205421</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-08-28T12:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: Problem name table with float numbers</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/680013#M205426</link>
      <description>&lt;P&gt;As other have already remarked, macro numbers are always whole numbers. So you would have to do something else to get that number, e.g.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro table_result(V,threshold);
  %local i;
  %do i=10 %to &amp;amp;threshold.0 %by 5;
    %macro2(&amp;amp;V,%substr(&amp;amp;i,1,%length(&amp;amp;i)-1).%substr(&amp;amp;i,%length(&amp;amp;i)));
    %end;
%mend;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As you cannot have periods/decimal points in a normal SAS table name, you would have to do something else, one possibility is to use this syntax:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;create table "table_&amp;amp;threshold"n&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will work, but you will have to refer to the table in the same way in your program, e.g. 'table_1.5'n&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>Fri, 28 Aug 2020 13:12:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Problem-name-table-with-float-numbers/m-p/680013#M205426</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2020-08-28T13:12:08Z</dc:date>
    </item>
  </channel>
</rss>

