<?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: proc sql send result count in macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/402761#M25848</link>
    <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used the SAS code for the macro . It's a excellent code . I can obtain the result of count in the log and in a table &lt;img id="manwink" class="emoticon emoticon-manwink" src="https://communities.sas.com/i/smilies/16x16_man-wink.png" alt="Man Wink" title="Man Wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;options compress=yes sortsize=max;

/* call database */

libname b8x meta library="my_data_base_john_doe";

/* macro to count lines */

%macro countrecs (dsn=);

   proc sql noprint;

   create table counts as 
   
   select count(*) as record_count 
   
   from &amp;amp;dsn;

   quit;

   data _null_;

      set counts;

      call symputx('nb_line', record_count, 'G');

   run;

%mend countrecs;

proc sql inobs=2500;

/* see several information on table */

create table consultation_abcd as select * from b8x.abcd; 
create table consultation_efgh as select * from b8x.efgh;

run; 

%countrecs (dsn=b8x.AB4D)

%put Number of lines: &amp;amp;nb_line;&lt;/PRE&gt;&lt;P&gt;Inside this SAS code I have had my proc sql.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for you help &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 14:11:17 GMT</pubDate>
    <dc:creator>azertyuiop</dc:creator>
    <dc:date>2017-10-10T14:11:17Z</dc:date>
    <item>
      <title>proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401303#M25773</link>
      <description>&lt;P&gt;Hello / good morning ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want generate a count with a proc sql and send the result in a variable. I have report the macro and the variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%mend test_macro;
 
proc sql;
 
/* count line */
 
create table my_new_table as
 
select count(id) as nb_line 
into :nb_line
from database.original_table;
 
run;
 
%test_macro;
 
/* print resultat in exit/newpaper of SAS */
 
%put number of line : &amp;amp;nb_line;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The macro isn't read by SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This message appear to in bleu/green in the exit/newspaper of SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%put number of line : &amp;amp;nb_line; /* */
WARNING: Apparent symbolic reference nb_line not resolved.&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;If you see the problem can give me your opinion to fix this bug ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 12:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401303#M25773</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-10-05T12:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401306#M25774</link>
      <description>&lt;P&gt;If you create the macro variable inside a macro it is local to tha macro.&lt;/P&gt;
&lt;P&gt;If so, make it global as the first step of your program:&lt;/P&gt;
&lt;P&gt;%global nb_line;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 12:47:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401306#M25774</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2017-10-05T12:47:27Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401316#M25775</link>
      <description>&lt;P&gt;Why are you even use a macro? You don't have any parmeters... What is the end goal for this logic?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:01:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401316#M25775</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-10-05T13:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401322#M25776</link>
      <description>&lt;P&gt;Look up macro variable scope in the documentation, that macro variable is local to the macro call so removed after that macro is resolved.&amp;nbsp; I agree with&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&amp;nbsp;that there is no need for this code, and I advise against creating global macro variables, if its just your code running then it may be fine, but on any enterprise system or multi-user etc. you could get all kinds of unwanted results.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:15:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401322#M25776</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-05T13:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401324#M25778</link>
      <description>&lt;P&gt;But the global macro variable is only global to the current SAS session ,right?&lt;/P&gt;
&lt;P&gt;So it should only be a problem if several users with different programs access the same session?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401324#M25778</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2017-10-05T13:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401325#M25779</link>
      <description>&lt;P&gt;Depends on the setup.&amp;nbsp; Anyways, you should always aim to write code which is nicely encapsulated, imagine if another user uses your macro code and it changes their macro variables, it can create really problematic debug issues.&amp;nbsp; And rarely is there a need for global ones anyway, some system level setups maybe, but actual code, never.&amp;nbsp; There are many methodologies to avoid such things.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:29:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401325#M25779</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-05T13:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401332#M25782</link>
      <description>&lt;P&gt;I agree, a good Point &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 13:41:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401332#M25782</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2017-10-05T13:41:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401365#M25785</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165260"&gt;@azertyuiop&lt;/a&gt; wrote:&lt;BR /&gt;&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%mend test_macro;
 
proc sql;
 
/* count line */
 
create table my_new_table as
 
select count(id) as nb_line 
into :nb_line
from database.original_table;
 
run;
 
%test_macro;
 
/* print resultat in exit/newpaper of SAS */
 
%put number of line : &amp;amp;nb_line;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I see a %mend without a %macro, so this code piece won't work at all.&lt;/P&gt;
&lt;P&gt;Make sure that you post your whole code.&lt;/P&gt;
&lt;P&gt;The log:&lt;/P&gt;
&lt;PRE&gt;ERROR: No matching %MACRO statement for this %MEND statement.
24         %mend test_macro;
25         
26         proc sql;
27         
28         /* count line */
29         
30         create table my_new_table as
31         
32         select count(id) as nb_line
33         into :nb_line
34         from database.original_table;
WARNING: INTO clause is ignored in the CREATE TABLE statement.
ERROR: Libref DATABASE is not assigned.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
35         
36         run;
NOTE: PROC SQL statements are executed immediately; The RUN statement has no effect.
37         
38         %test_macro;
           _
           180
WARNING: Apparent invocation of macro TEST_MACRO not resolved.
ERROR 180-322: Statement is not valid or it is used out of proper order.

39         
40         /* print resultat in exit/newpaper of SAS */
41         
42         %put number of line : &amp;amp;nb_line;
WARNING: Apparent symbolic reference NB_LINE not resolved.
number of line : &amp;amp;nb_line
&lt;/PRE&gt;
&lt;P&gt;The only error that could be ignored is the one about the missing library.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401365#M25785</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T14:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401371#M25786</link>
      <description>&lt;P&gt;There are a host of issues with this code, which makes it a shot in the dark as to how to correct it.&amp;nbsp; However, the issue of %LOCAL vs. %GLOBAL is not one of them.&amp;nbsp; The PROC SQL appears outside of a macro definition, and thus has to create a %GLOBAL macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Does %TESTDATA create database.original_table?&amp;nbsp; If so, %TESTDATA needs to run before PROC SQL can process the output data set.&lt;/LI&gt;
&lt;LI&gt;PROC SQL should end with QUIT; not with RUN;&lt;/LI&gt;
&lt;LI&gt;Why is PROC SQL creating a table?&amp;nbsp; You can create a macro variable without creating a table.&lt;/LI&gt;
&lt;LI&gt;What does the log say about the results of the PROC SQL?&lt;/LI&gt;
&lt;LI&gt;Do you really want a count of ID, vs. a count of distinct ID?&amp;nbsp; Do you just want a count of all the observations in the database.original_table?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:51:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401371#M25786</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-05T14:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401373#M25788</link>
      <description>&lt;P&gt;Actually,&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
 
/* count line */
 
create table my_new_table as
 
select count(name) as nb_line
into :nb_line
from sashelp.class;
 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces this log:&lt;/P&gt;
&lt;PRE&gt;26         proc sql;
27         
28         /* count line */
29         
30         create table my_new_table as
31         
32         select count(name) as nb_line
33         into :nb_line
34         from sashelp.class;
WARNING: INTO clause is ignored in the CREATE TABLE statement.
NOTE: Table WORK.MY_NEW_TABLE created, with 1 rows and 1 columns.
&lt;/PRE&gt;
&lt;P&gt;which means that the into: won't work anyway.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2017 14:56:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401373#M25788</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-05T14:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401638#M25797</link>
      <description>&lt;P&gt;Hello or Good morning ,&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13827"&gt;@FredrikE&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;I have tryed the instruction " %global nb_line; " but there is again the even message in green/blue.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;I use a macro to stock the quantity of line in a variable to reuse the result in several counts.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks for the technical information about number of user and macro in SAS .&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;I correct the structure of the programm with %macro and %mend.&lt;BR /&gt;&lt;BR /&gt;I correct the structure of my program to test this.&lt;BR /&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;" Does %TESTDATA create database.original_table? " &amp;gt; The macro " %TESTDATA " must be only save the result count of proc sql.&lt;BR /&gt;&lt;BR /&gt;" Why is PROC SQL creating a table? " &amp;gt; I want to stock the result of count in a variable because when I use the instruction "count"&amp;nbsp; in my PROC SQL the result it's an easy board with only one cell .&lt;BR /&gt;&lt;BR /&gt;" What does the log say about the results of the PROC SQL? " &amp;gt; I want see in the log the result with this function " %put number of line : &amp;amp;nb_line; " which give the quantity of line in my table.&lt;BR /&gt;&lt;BR /&gt;" Do you really want a count of ID, vs. a count of distinct ID?&amp;nbsp; Do you just want a count of all the observations in the database.original_table? " &amp;gt; I want count all line of the table without a distinct .&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 07:37:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401638#M25797</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-10-06T07:37:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401644#M25798</link>
      <description>&lt;P&gt;So why do you need this setup:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%put number of line : &amp;amp;nb_line;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am asking for two reasons, firstly if your not doing generic code it will just make your code more complex and liable to fall over, and secondly macro variables are text, so numbers are just text leading to conversions and such like.&amp;nbsp; Use Base SAS all the time, it has all the functionality you need.&amp;nbsp; If you have to do this, then consider this code (i have corrected all the mistakes as well):&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;%macro test_macro;
 
  proc sql noprint;
    select count(age) as nb_line 
    into :nb_line
    from sashelp.class;
  quit;
  &amp;amp;nbline.
 
%mend test_macro;
 
%put number of line : &amp;amp;nb_line;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The macro resolves to the string 19.&amp;nbsp; No need ot pass macro parameters back and forth or create global ones.&amp;nbsp; Even this however has pretty much zero use and doesn't really do anything. You can get a nice dataset from proc freq, or create one from proc sql and then use that data in further processing.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 08:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401644#M25798</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-06T08:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401645#M25799</link>
      <description>&lt;P&gt;I have tryed this macro :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro test(var=);

count(&amp;amp;var);

%mend;

data work.temp;
set mybdd.mytable;
call symput(myfield);

run ;&lt;/PRE&gt;&lt;P&gt;There is this message of error in logs :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ERROR 252-185: The SYMPUT subroutine call does not have enough arguments.&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2017 08:32:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401645#M25799</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-10-06T08:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401649#M25800</link>
      <description>&lt;P&gt;I feel a bit confused now, this is a new piece of code....&lt;/P&gt;
&lt;P&gt;Have you read the documentation for call symput?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you want the Count statement to achieve?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this meta code or your actual work?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;//Fredrik&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 08:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401649#M25800</guid>
      <dc:creator>FredrikE</dc:creator>
      <dc:date>2017-10-06T08:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401651#M25801</link>
      <description>&lt;P&gt;Me too!&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 08:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401651#M25801</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-10-06T08:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401660#M25802</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165260"&gt;@azertyuiop&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have tryed this macro :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;%macro test(var=);

count(&amp;amp;var);

%mend;

data work.temp;
set mybdd.mytable;
call symput(myfield);

run ;&lt;/PRE&gt;
&lt;P&gt;There is this message of error in logs :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ERROR 252-185: The SYMPUT subroutine call does not have enough arguments.&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You obviously have not read the documentation. Do so to avoid such extremely simple mistakes. The documentation is there for a reason, not consulting it is a sign of foolishness.&lt;/P&gt;
&lt;P&gt;call symput() requires TWO arguments.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 09:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401660#M25802</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-06T09:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401662#M25803</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;@&lt;SPAN class="UserName lia-user-name lia-user-rank-Regular-Contributor"&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13827" target="_self"&gt;&lt;SPAN class="login-bold"&gt;FredrikE and&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="UserName lia-user-name lia-user-rank-Regular-Contributor"&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes I have read several documentations about SAS macro in PDF 130-30 , 243-29 , base_macro_6997 , p071-27 .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want that the macro count the number of line in a table. Why I use a macro , because to develop my SAS program in the futur I want use several time this macro , for several count in 4 or 6 tables.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you want give an opinion on the SAS code , my actual code is this :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%macro test(var=);

count(&amp;amp;var);

%mend;

data work.temp;
set mybdd.mytable;
call symput(myfield);

run ;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 09:24:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401662#M25803</guid>
      <dc:creator>azertyuiop</dc:creator>
      <dc:date>2017-10-06T09:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401665#M25804</link>
      <description>&lt;P&gt;If you had read the macro documentation, you would know how to use call symput, as it is part of the macro/data step interface.&lt;/P&gt;
&lt;P&gt;Your code has obvious errors (I gave you the reason in my previous post), and it won't work.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 09:36:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401665#M25804</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-06T09:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401720#M25806</link>
      <description>&lt;P&gt;As you can see from all the questions here, your code is far from working.&amp;nbsp; I will give you something that works (I think), but you still have a lot of studying to do to understand why this code works and your code doesn't.&amp;nbsp; (At least I'm assuming this code works.&amp;nbsp; It might need minor tweaking, since I can't test it.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro countrecs (dsn=);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; proc sql noprint;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; create table counts as select count(*) as record_count from &amp;amp;dsn;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; data _null_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; set counts;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; call symputx('nb_line', record_count, 'G');&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;%mend countrecs;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you could test it with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%countrecs (dsn=database.original_table)&lt;/P&gt;
&lt;P&gt;%put Number of lines:&amp;nbsp; &amp;amp;nb_line;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that I removed ID from the code.&amp;nbsp; Presumably, you would like your code to run even if the incoming data does not contain a field named ID.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 12:41:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401720#M25806</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-10-06T12:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql send result count in macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401841#M25822</link>
      <description>&lt;P&gt;&lt;FONT color="#800080" face="arial black,avant garde" size="5"&gt;&lt;STRONG&gt;Please Provide some example input data and an example of what the final result should be. Posting non-working code does not describe the actual issue or result.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000" face="arial,helvetica,sans-serif" size="3"&gt;There are so many ways to count things in SAS and then combine that result with something else that choices need to be made based on something concrete. For instance if this is involved is displaying a result a human reads such as a report one way may be more appropriate than if the value is to be added to a data set and used for computation.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2017 16:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/proc-sql-send-result-count-in-macro/m-p/401841#M25822</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-06T16:39:25Z</dc:date>
    </item>
  </channel>
</rss>

