<?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: Add a value to a Macro-Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920690#M362613</link>
    <description>&lt;P&gt;Thanks Bard.&lt;/P&gt;&lt;P&gt;Had to change the if statement to:&lt;/P&gt;&lt;P&gt;%let pos_found = %sysfunc(findw(&amp;amp;mvName., &amp;amp;val.));&lt;/P&gt;&lt;P&gt;%if &amp;amp;pos_found = 0 %then % do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is still not allowed:&lt;/P&gt;&lt;P&gt;%let &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;mvName. = &amp;amp;&amp;amp;&amp;amp;mvName.&amp;nbsp;&amp;nbsp; &amp;amp;val.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Expecting a variable name after %let.&lt;/P&gt;&lt;P&gt;ERROR: The macro variable name is either all blank or missing.&lt;/P&gt;</description>
    <pubDate>Mon, 18 Mar 2024 12:26:04 GMT</pubDate>
    <dc:creator>obvisou</dc:creator>
    <dc:date>2024-03-18T12:26:04Z</dc:date>
    <item>
      <title>Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920638#M362599</link>
      <description>&lt;P&gt;Hi all,&lt;BR /&gt;I would like to add a new value in an existing Macro-Variable. The new value should only be added if is not already part of the Macro-Variable.&lt;BR /&gt;Adding a value works fine:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let parameter_macrovariable = &amp;amp;parameter_macrovariable. &amp;amp;parameter_value.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;To do the check I would like to use a Macro (if there is not a better way to do it). I haven't find a solution to work inside the Macro with the literal name of Inputparamter in the macro (parameter_macrovariable &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; The assignment inside a macro is different. This is in SAS not allowed: %let %parameter_macrovariable. = ...&lt;/P&gt;&lt;P&gt;Thank you for your help. Here my not working macro:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%global macrovariable
%let macrovariable = Value1

%macro check_and_add(parameter_macrovariable =, parameter_value =);

    %let found = %sysfunc(findw(&amp;amp;parameter_macrovariable., &amp;amp;parameter_value., %str( )));
    %if &amp;amp;found. = 0 %then %do;
        %let parameter_macrovariable = &amp;amp;parameter_macrovariable. &amp;amp;parameter_value.;
		%put Updated list: &amp;amp;parameter_macrovariable., new added value: &amp;amp;parameter_value.;
    %end;

%mend;

%check_and_add(parameter_macrovariable = macrovariable, parameter_value = Value2)

%put parameter_macrovariable: parameter_macrovariable; /* Result: empty */&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 07:40:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920638#M362599</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T07:40:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920642#M362600</link>
      <description>&lt;P&gt;when you use a variable in as a parameter in a macro it is definled in the local macro variable table and is not availble outside the macro. You need do define it before.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let macrovariable = Value1;
%let parameter_macrovariable = &amp;amp;macrovariable;

%macro check_and_add( parameter_value =);
    %let found = %sysfunc(findw(&amp;amp;parameter_macrovariable., &amp;amp;parameter_value.));
    %if &amp;amp;found. = 0 %then %do;
        %let parameter_macrovariable = &amp;amp;parameter_macrovariable. &amp;amp;parameter_value.;
		%put Updated list: &amp;amp;parameter_macrovariable., new added value: &amp;amp;parameter_value.;
    %end;
%put &amp;amp;=parameter_macrovariable; 
%mend;

%check_and_add(parameter_value = Value2)

%put &amp;amp;=parameter_macrovariable; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 08:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920642#M362600</guid>
      <dc:creator>rudfaden</dc:creator>
      <dc:date>2024-03-18T08:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920664#M362605</link>
      <description>&lt;P&gt;Thank you. But this is not want I want. The Macro should be dynamic and be used also for other Macro-Variables, so it is necessary to have two Input-Parameters. One for the Macro-Variable (List) to be updated and second for the Value who must be added or not (parameter_macrovariable =, parameter_value &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 10:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920664#M362605</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T10:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920666#M362607</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%global myMacrovariable;
%let myMacrovariable = A;

%put &amp;amp;=myMacrovariable.;

%macro add_value(val,mvName=myMacrovariable)/minoperator mindelimiter=' ';
%if NOT (&amp;amp;val. in (&amp;amp;&amp;amp;&amp;amp;mvName.)) %then
  %let &amp;amp;mvName. = &amp;amp;&amp;amp;&amp;amp;mvName. &amp;amp;val.;
%mend add_value;

%add_value(A)
%put &amp;amp;=myMacrovariable.;

%add_value(B)
%put &amp;amp;=myMacrovariable.;

%add_value(C)
%put &amp;amp;=myMacrovariable.;

%add_value(C)
%put &amp;amp;=myMacrovariable.;

%add_value(A)
%put &amp;amp;=myMacrovariable.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course the assumption is that values you're adding don't have spaces in them.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 10:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920666#M362607</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T10:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920668#M362608</link>
      <description>&lt;P&gt;An alternative could be to add everything as it goes to the variable value, and when it's done, to use the&amp;nbsp;&lt;A href="https://github.com/SASPAC/baseplus/blob/main/baseplus.md#-deduplists-macro--" target="_self"&gt;%dedupListS()&lt;/A&gt; macro from the &lt;A href="https://github.com/SASPAC/baseplus" target="_self"&gt;BasePlus package&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; %let list = 4 5 6 1 2 3 1 2 3 4 5 6;
 %let list = %dedupListS(&amp;amp;list.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 11:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920668#M362608</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T11:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920690#M362613</link>
      <description>&lt;P&gt;Thanks Bard.&lt;/P&gt;&lt;P&gt;Had to change the if statement to:&lt;/P&gt;&lt;P&gt;%let pos_found = %sysfunc(findw(&amp;amp;mvName., &amp;amp;val.));&lt;/P&gt;&lt;P&gt;%if &amp;amp;pos_found = 0 %then % do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this is still not allowed:&lt;/P&gt;&lt;P&gt;%let &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt;&lt;/FONT&gt;mvName. = &amp;amp;&amp;amp;&amp;amp;mvName.&amp;nbsp;&amp;nbsp; &amp;amp;val.;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Expecting a variable name after %let.&lt;/P&gt;&lt;P&gt;ERROR: The macro variable name is either all blank or missing.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 12:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920690#M362613</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T12:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920693#M362614</link>
      <description>&lt;P&gt;Full log please...&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 12:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920693#M362614</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T12:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920694#M362615</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;ERROR: The macro variable name is either all blank or missing.&lt;/SPAN&gt;" - did you defined your macro variable BEFORE running the macro ?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 12:29:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920694#M362615</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T12:29:41Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920703#M362622</link>
      <description>&lt;PRE&gt;&lt;CODE class=""&gt;%MACRO ChkValueList_Add(p_list     =                            
                           ,p_value    =                            
                           )/minoperator mindelimiter = ' ';


/*----------------------------------------------------------------
  Parameter
----------------------------------------------------------------*/
%put @_&amp;amp;sysmacroname._500_p_list:          &amp;amp;p_list.;
%put @_&amp;amp;sysmacroname._502_p_value:         &amp;amp;p_value.;


/*----------------------------------------------------------------
  Check
----------------------------------------------------------------*/
%if %length(&amp;amp;p_value.) = 0 %then %do;
   %put ERROR: Parameter 'p_value' ist leer. (ku-508);
   %return;
%end;


/*----------------------------------------------------------------
  
----------------------------------------------------------------*/
%let pos_found = %sysfunc(findw(&amp;amp;p_list., &amp;amp;p_value.));           /* */ 
/*%if NOT (&amp;amp;p_value. IN (&amp;amp;&amp;amp;&amp;amp;p_list.)) %then %do;                 /* */ 
   %put @_&amp;amp;sysmacroname._517_Position_Found:  &amp;amp;pos_found.;

%if &amp;amp;pos_found. = 0 %then %do;               
   %let &amp;amp;p_list. = &amp;amp;&amp;amp;&amp;amp;p_list. &amp;amp;p_value.;     

   %put @_&amp;amp;sysmacroname._522:  Wert (&amp;amp;p_value.) wurde in Liste hinzugefügt (&amp;amp;p_list.).;
%end;
%else %do;
   %put @_&amp;amp;sysmacroname._525:  Wert (&amp;amp;p_value.) ist bereits in Liste enthalten (&amp;amp;p_list.).;		/* nicht möglich Name der Liste anzuzeigen!!!)
%end;

%put;
%put #---------------------------------------------------#;
%put # &amp;amp;sysmacroname._End;
%put #---------------------------------------------------#;

%MEND ChkValueList_Add;



------------------------------------------------------------------------------
 
------------------------------------------------------------------------------
%global list_epi list_add;
%let list_epi               =;                                       
%let list_add               =;                                       
/* */

%include "/......_ChkVariableExist.sas";    
%ChkValueList_Add(p_list= &amp;amp;list_epi., p_value= Hallo); 
%put ----list_epi:  &amp;amp;list_epi.;


------------------------------------------------------------------------------
 Log
------------------------------------------------------------------------------
1          ;*';*";*/;quit;run;
2          OPTIONS PAGENO=MIN;
3          %LET _CLIENTTASKLABEL='Config';
4          %LET _CLIENTPROCESSFLOWNAME='Manual';
5          %LET _CLIENTPROJECTPATH='/SAS/......egp';
6          %LET _CLIENTPROJECTPATHHOST='........';
7          %LET _CLIENTPROJECTNAME='.......egp';
8          %LET _SASPROGRAMFILE='';
9          %LET _SASPROGRAMFILEHOST='';
10         
11         ODS _ALL_ CLOSE;
12         OPTIONS DEV=SVG;
13         GOPTIONS XPIXELS=0 YPIXELS=0;
14         %macro HTML5AccessibleGraphSupported;
15             %if %_SAS_VERCOMP_FV(9,4,4, 0,0,0) &amp;gt;= 0 %then ACCESSIBLE_GRAPH;
16         %mend;
17         FILENAME EGHTML TEMP;
18         ODS HTML5(ID=EGHTML) FILE=EGHTML
19             OPTIONS(BITMAP_MODE='INLINE')
20             %HTML5AccessibleGraphSupported
MPRINT(HTML5ACCESSIBLEGRAPHSUPPORTED):   ACCESSIBLE_GRAPH
21             ENCODING='utf-8'
22             STYLE=HTMLBlue
23             NOGTITLE
24             NOGFOOTNOTE
25             GPATH=&amp;amp;sasworklocation
26         ;
27         
28         
29         %include "/SAS/................sas";
574        %ChkValueList_Add(p_list= &amp;amp;list_epi., p_value= Hallo);


#---------------------------------------------------#
# ChkValueList_Add_Start
#---------------------------------------------------#
@_ChkValueList_Add_500_p_list:
ERROR: Expecting a variable name after %LET.
ERROR: The macro variable name is either all blank or missing.
ERROR: The macro ChkValueList_Add will stop executing.
575        
576    
578        
579        %put ----list_epi:  &amp;amp;list_epi.;
----list_epi:
580        %put &amp;amp;=list_epi;
LIST_EPI=
581        /* */
582        
583        
584        %LET _CLIENTTASKLABEL=;
585        %LET _CLIENTPROCESSFLOWNAME=;
586        %LET _CLIENTPROJECTPATH=;
587        %LET _CLIENTPROJECTPATHHOST=;
588        %LET _CLIENTPROJECTNAME=;
589        %LET _SASPROGRAMFILE=;
2                                                          The SAS System                               09:26 Monday, March 18, 2024

590        %LET _SASPROGRAMFILEHOST=;
591        
592        ;*';*";*/;quit;run;
593        ODS _ALL_ CLOSE;
594        
595        
596        QUIT; RUN;
597        






&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 18 Mar 2024 12:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920703#M362622</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T12:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920704#M362623</link>
      <description>&lt;P&gt;To reference the value of macro variable whose name is stored in a macro variable you need to add more &amp;amp;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;&amp;amp;&amp;amp;mvar&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first two resolve to one and trigger the macro processor to re-scan the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So your macro should look more like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check_and_add(mvar=,value=);
%if 0=%length(&amp;amp;mvar) %then %put ERROR: MVAR not specified.;
%else %do;
  %if not %symexist(&amp;amp;mvar) %then %global &amp;amp;mvar;
  %if not %sysfunc(findw(&amp;amp;&amp;amp;&amp;amp;mvar,&amp;amp;value,,s)) %then %do;
      %let &amp;amp;mvar = &amp;amp;&amp;amp;&amp;amp;mvar &amp;amp;value ;
      %put Updated list: &amp;amp;mvar=&amp;amp;&amp;amp;&amp;amp;mvar ;
  %end;
%end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS&amp;nbsp; Using variable names that are too long is just as hard to understand as using variable names that are too short. And much harder to type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;CORRECTED&lt;/STRONG&gt;: Fixed the call to FINDW() to use S modifier instead of trying to get %SYSFUNC() to pass a single space as the delimiter list.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 16:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920704#M362623</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-18T16:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920711#M362625</link>
      <description>&lt;P&gt;If had already &amp;amp;&amp;amp;&amp;amp;:&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;%let &amp;amp;mvar = &amp;amp;&amp;amp;&amp;amp;mvar &amp;amp;value ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let &amp;amp;p_list. = &amp;amp;&amp;amp;&amp;amp;p_list. &amp;amp;p_value.;   &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I realy wonderig why it is working in your case?&lt;/P&gt;&lt;P&gt;And this is also not the goal:&lt;/P&gt;&lt;PRE class=""&gt;&lt;CODE&gt;%then %global &amp;amp;mvar;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The variable must be global outside the macro. So it can be reused.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AI is very bad in SAS &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:19:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920711#M362625</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T13:19:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920713#M362627</link>
      <description>&lt;P&gt;Great, but where is your log with the code I proposed ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:25:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920713#M362627</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T13:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920714#M362628</link>
      <description>&lt;P&gt;This comment seems to be not closed:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* nicht möglich Name der Liste anzuzeigen!!!)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:27:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920714#M362628</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T13:27:24Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920715#M362629</link>
      <description>&lt;P&gt;You did not use the &amp;amp;&amp;amp;&amp;amp; in the FINDW() function call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The %IF %SYMEXIST()... statement is to define &amp;amp;MAR as global when it does not already exist.&amp;nbsp; Otherwise it will be defined as local and disappear when the macro ends.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need to define &amp;amp;MVAR as GLOBAL if it already exists.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't want to define &amp;amp;MVAR as GLOBAL if it already exists as LOCAL in some other macro that is calling this macro.&amp;nbsp; SAS will generate and error.&lt;/P&gt;
&lt;P&gt;Hence the use of the %IF statement.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:38:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920715#M362629</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-03-18T13:38:02Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920716#M362630</link>
      <description>&lt;P&gt;This line is badly commented out too:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*%if NOT (&amp;amp;p_value. IN (&amp;amp;&amp;amp;&amp;amp;p_list.)) %then %do;                 /* */ &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920716#M362630</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T13:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920717#M362631</link>
      <description>&lt;P&gt;yes sorry, but this is not the mistake.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:28:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920717#M362631</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T13:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920719#M362632</link>
      <description>&lt;P&gt;Is here&amp;nbsp; something wrong? It was your suggestion. I don't need it. just deleted.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:30:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920719#M362632</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T13:30:13Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920720#M362633</link>
      <description>&lt;P&gt;Take the code I posted, copy it to your session, run it, and share the results, ok ?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920720#M362633</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-18T13:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920723#M362635</link>
      <description>&lt;P&gt;The if-statement worked fine. If change &amp;amp;&amp;amp;&amp;amp; in the fincw() function I got an Error. The error occurs in the assigment %let =. Please concentrate on that.&lt;/P&gt;&lt;P&gt;"The %IF statement will only define &amp;amp;MAR as global when it is needed." - The variable is global and should stay global because it will be reused, e.g.:&lt;/P&gt;&lt;LI-CODE lang="sas"&gt;check_and_add(mvar= mvar,value= Value1);
check_and_add(mvar= mvar,value= Value1);
check_and_add(mvar= mvar,value= Value2);
check_and_add(mvar= mvar,value= Value2);
check_and_add(mvar= mvar,value= Value3);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:39:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920723#M362635</guid>
      <dc:creator>obvisou</dc:creator>
      <dc:date>2024-03-18T13:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add a value to a Macro-Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920729#M362639</link>
      <description>&lt;PRE&gt;%global macrovariable;

%let macrovariable = Value1;

%macro check_and_add(parameter_macrovariable =, parameter_value =);
    %if ^%index(%bquote(&amp;amp;&amp;amp;&amp;amp;parameter_macrovariable), &amp;amp;parameter_value) %then %do;
        %let &amp;amp;parameter_macrovariable = &amp;amp;&amp;amp;&amp;amp;parameter_macrovariable. &amp;amp;parameter_value.;
		%put Updated list: &amp;amp;parameter_macrovariable., new added value: &amp;amp;parameter_value.;
    %end;

%mend;

%check_and_add(parameter_macrovariable = macrovariable, parameter_value = Value2);

%put &amp;amp;=macrovariable;&lt;/PRE&gt;&lt;P&gt;Is this what you want?&amp;nbsp;&lt;BR /&gt;The code supplied by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt; works well too &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;@&lt;/P&gt;</description>
      <pubDate>Mon, 18 Mar 2024 13:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-a-value-to-a-Macro-Variable/m-p/920729#M362639</guid>
      <dc:creator>Mazi</dc:creator>
      <dc:date>2024-03-18T13:46:49Z</dc:date>
    </item>
  </channel>
</rss>

