<?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: Extract  variable names using prx expression in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920932#M362714</link>
    <description>&lt;P&gt;1- Yes the goal is to extract the variable name from&amp;nbsp;&lt;SPAN&gt;[some text]&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;varname1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&amp;lt;@&lt;/SPAN&gt;&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;varname2 &lt;/STRONG&gt;under the hypothesis that we could have multiple variable names with some diversity in the characters composing those names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- The expected from&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;test1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;test2 &lt;/STRONG&gt;is to contain the values + separator : / as an example : aeterm1/aedecod1 or /aeterm2/aedecod2/ and the goal is to exclude the separator when the variables are empty and avoid the single separator from displaying in the report in that case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3- The dataset could adae or another one and we need to concatenate two or more variables with the separator (any symbol that will be inserted between variable values: &amp;lt;/&amp;gt; &amp;lt;#&amp;gt; &amp;lt;$&amp;gt; &amp;lt;-&amp;gt; &amp;lt;&amp;gt; &amp;lt;(&amp;gt; &amp;lt;)&amp;gt; &amp;lt;!&amp;gt; &amp;lt;|&amp;gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Mar 2024 14:56:33 GMT</pubDate>
    <dc:creator>hamza_saspg</dc:creator>
    <dc:date>2024-03-19T14:56:33Z</dc:date>
    <item>
      <title>Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920899#M362699</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to extract the variable names from the given macro variable &amp;amp;var (which is not working well using prxposn), then test if they are empty. If it is the case so I need to delete the separator (slash / in this case) and obtain an empty column in the output instead of that separator alone when the variables are empty and the concatenation result should be stored in the variable code.&lt;/P&gt;&lt;P&gt;The below approach is based on prx expressions since I don't have a control on the variable name that will be mentioned in the macro variable &amp;amp;var used as&amp;nbsp; input (it happens that the variable name contains digits and it should be the ones before and after &amp;lt;&amp;gt;). The concatenation result should be stored in the variable code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let var = [aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm ; /*here aedecod and aeterm are two variables included in the dataset adae, but we could replace them by other ones*/&lt;BR /&gt;data want;&lt;BR /&gt;set adae ;&lt;/P&gt;&lt;P&gt;patternID1=prxparse("/(\[(\w+)\])?\s*(\w*)/");&lt;BR /&gt;/* define a pattern for &amp;lt;Separator1DigitsSeparator2&amp;gt; Variable2 */&lt;BR /&gt;patternID2=prxparse("/&amp;lt;([^&amp;lt;&amp;gt;0-9]*)(\d*)([^&amp;lt;&amp;gt;0-9]*)&amp;gt;\s*(\w*)/");&lt;BR /&gt;/* define a pattern for matched braces ')' or '(' */&lt;BR /&gt;patternID3=prxparse("/&amp;lt;[^a-zA-Z\&amp;lt;\&amp;gt;]*(\(|\))[^a=zA-Z\&amp;lt;\&amp;gt;]*\&amp;gt;/");&lt;BR /&gt;do i=1 to 2;&lt;BR /&gt;test1= scan("[aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm" , i , '&amp;lt;&amp;gt;' ) ;&lt;BR /&gt;test2=prxposn(patternID1,3,test1);&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;varlist= test2 ;&lt;BR /&gt;if test2ne '' and test2 ne '.' then do;&lt;BR /&gt;&lt;BR /&gt;code=cats('strip(put(',test2,',',vformatx(test2),'))');&lt;BR /&gt;label=vlabelx(test2);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;end;&lt;BR /&gt;else do;&lt;BR /&gt;code='';&lt;BR /&gt;label='';&lt;BR /&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope I have clarified enough the problem and thanks in advance for your help.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 11:13:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920899#M362699</guid>
      <dc:creator>hamza_saspg</dc:creator>
      <dc:date>2024-03-19T11:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920907#M362703</link>
      <description>&lt;P&gt;Maybe try &lt;A href="https://github.com/SASPAC/baseplus" target="_self"&gt;BasePlus package&lt;/A&gt; and the &lt;A href="https://github.com/SASPAC/baseplus/blob/main/baseplus.md#-getvars-macro--" target="_self"&gt;%getVars()&lt;/A&gt; macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example 3:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %put *%getVars(sashelp.class, pattern=i|a)*;

  %put *%getVars(sashelp.class, pattern=^w)*;

  %put *%getVars(sashelp.class, pattern=ght$)*;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or Example 4:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  %put *%getVars(sashelp.class, sep=+, pattern=^(w|h)|x$, varRange=_numeric_)*;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 11:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920907#M362703</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-19T11:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920908#M362704</link>
      <description>&lt;P&gt;The golden rule says: "if you can solve it with or without regular expressions, solve it without":&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var = [aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm ;

data _null_;
str=symget('var');
length v $ 32;
do i = 1 to countw(str, " ");
  v = compress(scan(str,i, " "),"_","KAD");
  call symputX(cats("V_",i),v, "G");
end;
run;

%put &amp;amp;=V_1. &amp;amp;=V_2. &amp;amp;=V_3. &amp;amp;=V_4.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 12:02:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920908#M362704</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-19T12:02:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920913#M362705</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Is the text in the macro variable consistently laid out like this, and you just want to extract &lt;STRONG&gt;varname1&lt;/STRONG&gt; and &lt;STRONG&gt;varname2&lt;/STRONG&gt;? Or does the layout vary?&lt;BR /&gt;[some text] &lt;STRONG&gt;varname1&lt;/STRONG&gt; &amp;lt;@&lt;EM&gt;n&lt;/EM&gt;&amp;gt; &lt;STRONG&gt;varname2&lt;/STRONG&gt;&lt;/LI&gt;
&lt;LI&gt;You provided a sample input value of "&lt;SPAN&gt;[aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm". What would the values of&amp;nbsp;&lt;STRONG&gt;test1&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;test2&lt;/STRONG&gt; be if your code was working the way you wanted it to work?&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;Please provide a simple sample of the dataset &lt;STRONG&gt;adae&lt;/STRONG&gt;. Your use of the functions VFORMATX and VLABLEX doesn't make without this for context.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 12:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920913#M362705</guid>
      <dc:creator>SASJedi</dc:creator>
      <dc:date>2024-03-19T12:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920918#M362706</link>
      <description>&lt;P&gt;Please answer&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi&lt;/a&gt;&amp;nbsp;very valid questions because if your source string has a "stable" pattern then things will become much easier and no RegEx will be required.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If things aren't that simple then which RegEx will work and how complex it needs to be to identify a SAS variable name without also picking false positives will very much depend on what patterns you have to cover.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With SAS data step syntax the following would be variables.&lt;/P&gt;
&lt;PRE&gt;first.varname
function(varname)
array_name[varname]
etc.&lt;/PRE&gt;
&lt;P&gt;The RegEx for a string that complies with SAS naming conventions for a variable could look like:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;[_[:alpha:]]\w{0,31}&lt;/PRE&gt;
&lt;P&gt;- one to 32 characters&lt;/P&gt;
&lt;P&gt;- First character is a letter or underscore&lt;/P&gt;
&lt;P&gt;- 2nd to 32th character is a underscore, letter or digit&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here some RegEx that returns the sub-strings you defined as desired.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
  source_string="[aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm";
  length found $32;
  _prxid=prxparse('/(^|[ ])([_[:alpha:]]\w{0,31})($|[ ])/i');
  _start = 1;
  _stop = length(source_string);
  call prxnext(_prxid, _start, _stop, trim(source_string), _pos, _len);
  do while (_pos &amp;gt; 0);
    found = prxposn(_prxid, 2, source_string);
    output;
    call prxnext(_prxid, _start, _stop, trim(source_string), _pos, _len);
  end;
run;

proc print data=test;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1710852267407.png" style="width: 610px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94754i449E94AF19E03A35/image-dimensions/610x86?v=v2" width="610" height="86" role="button" title="Patrick_0-1710852267407.png" alt="Patrick_0-1710852267407.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 12:47:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920918#M362706</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-03-19T12:47:53Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920924#M362709</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/23438"&gt;@hamza_saspg&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to extract the variable names from the given macro variable &amp;amp;var (which is not working well using prxposn), then test if they are empty.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What does "test if they are empty" mean? I don't see any code actually testing values of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS has MISSING, and can test for that.&lt;/P&gt;
&lt;P&gt;I would say that instead of bothering with such a macro use tools SAS has already provided such as Proc Freq with the NLEVELS option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;ods select nlevels;
ods output nlevels=myleveldataset; /* if you want a data set*/
proc freq data=yourdataset nlevels;
run;

&lt;/PRE&gt;
&lt;P&gt;For example running that on SASHELP.CLASS will show this content in the level dataset. If the NNonMissLevels is not equal to zero then that variable has at least one non-missing value.&lt;/P&gt;
&lt;P&gt;Nmiss of zero means that variable has no missing values at all.&lt;/P&gt;
&lt;PRE&gt;                                     NNon
Table                    NMiss        Miss
Var        NLevels      Levels      Levels

Name            19           0          19
Sex              2           0           2
Age              6           0           6
Height          17           0          17
Weight          15           0          15&lt;/PRE&gt;
&lt;P&gt;The Nmiss levels allows for the use of the special missing values so there is a potential of values up to 27: . .A through .Z and ._&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 14:14:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920924#M362709</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-19T14:14:14Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920932#M362714</link>
      <description>&lt;P&gt;1- Yes the goal is to extract the variable name from&amp;nbsp;&lt;SPAN&gt;[some text]&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;varname1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&amp;lt;@&lt;/SPAN&gt;&lt;EM&gt;n&lt;/EM&gt;&lt;SPAN&gt;&amp;gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;varname2 &lt;/STRONG&gt;under the hypothesis that we could have multiple variable names with some diversity in the characters composing those names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2- The expected from&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;test1&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;test2 &lt;/STRONG&gt;is to contain the values + separator : / as an example : aeterm1/aedecod1 or /aeterm2/aedecod2/ and the goal is to exclude the separator when the variables are empty and avoid the single separator from displaying in the report in that case&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3- The dataset could adae or another one and we need to concatenate two or more variables with the separator (any symbol that will be inserted between variable values: &amp;lt;/&amp;gt; &amp;lt;#&amp;gt; &amp;lt;$&amp;gt; &amp;lt;-&amp;gt; &amp;lt;&amp;gt; &amp;lt;(&amp;gt; &amp;lt;)&amp;gt; &amp;lt;!&amp;gt; &amp;lt;|&amp;gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 14:56:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920932#M362714</guid>
      <dc:creator>hamza_saspg</dc:creator>
      <dc:date>2024-03-19T14:56:33Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920935#M362716</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35763"&gt;@yabwon&lt;/a&gt;&amp;nbsp;I appreciate you way you simplify things! It works well when it's outside a macro structure, so I would prefer an approach based on prx functions to synchronize with my existing structure, Thanks!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 15:57:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920935#M362716</guid>
      <dc:creator>hamza_saspg</dc:creator>
      <dc:date>2024-03-19T15:57:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920938#M362717</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I see your point but the expected is to concatenate two empty variables and be able to exclude the separator in case one or multiple variables are empty, so I need an approach considering an existing structure based on prx functions and macros&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 16:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920938#M362717</guid>
      <dc:creator>hamza_saspg</dc:creator>
      <dc:date>2024-03-19T16:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920940#M362718</link>
      <description>&lt;P&gt;Making it a macro is almost trivial:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let var = [aeterm9] aedecod &amp;lt;/@2&amp;gt; aeterm ;

%macro cutIntoParts(varName);
%local i;
%do i = 1 %to %sysfunc(countw(%superq(&amp;amp;varName.), %str( )));
  %global V_&amp;amp;i.;
  %let V_&amp;amp;i. = %sysfunc(compress(%scan(%superq(&amp;amp;varName.), &amp;amp;i., %str( )),_,KAD));
%end;
%mend cutIntoParts;


%cutIntoParts(var)

%put &amp;amp;=V_1. &amp;amp;=V_2. &amp;amp;=V_3. &amp;amp;=V_4.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 16:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920940#M362718</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-03-19T16:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920942#M362719</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;it seems like your approach is matching exactly what I need, then I will be able to build on it and exclude the separator from the concatenation when one or multiple variables are empty. Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 16:28:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920942#M362719</guid>
      <dc:creator>hamza_saspg</dc:creator>
      <dc:date>2024-03-19T16:28:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extract  variable names using prx expression</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920944#M362720</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/23438"&gt;@hamza_saspg&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;I see your point but the expected is to concatenate two empty variables and be able to exclude the separator in case one or multiple variables are empty, so I need an approach considering an existing structure based on prx functions and macros&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Perhaps some examples of what you have and what you expect for output.&lt;/P&gt;
&lt;P&gt;The CATX function will insert a string as you describe if I understand the requirement.&lt;/P&gt;
&lt;PRE&gt;data example;
  var1 = '';
  var2 = 'sometext';
  var3 = '';
  var4 = 'something else';
  out1 = catx('|',var1,var2);
  out2 = catx('|',var1,var3,var2);
  out3 = catx('|',var1,var3,var2,var4);
  out4 = catx('|',var1,var1,var3);
  out5 = catx('|',var2,var1,var3,var4);
run;

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Mar 2024 16:31:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extract-variable-names-using-prx-expression/m-p/920944#M362720</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-19T16:31:44Z</dc:date>
    </item>
  </channel>
</rss>

