<?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 Macro for every columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853908#M337502</link>
    <description>&lt;P&gt;Hello SAS Buddies &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you be so polite and help me with small issue? I try to make a new dataset for every columns from my basic dataset. It's my basic dataset with Standardize Data and I would like to find outlier for every columns (like make a flag).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="325304895_577150883828567_1972157714311734525_n.png" style="width: 895px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79414i3241671DDAB52FD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="325304895_577150883828567_1972157714311734525_n.png" alt="325304895_577150883828567_1972157714311734525_n.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have someting like it;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="321638846_1167921607426705_4573772748608195385_n.png" style="width: 487px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79413iAD8F8247BEC5D75D/image-size/large?v=v2&amp;amp;px=999" role="button" title="321638846_1167921607426705_4573772748608195385_n.png" alt="321638846_1167921607426705_4573772748608195385_n.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried do it with below code;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table zbiory.name as 
    select NAME
    into     :NAMES separated by ' ' 
    from (select name from dictionary.columns
where libname = 'WORK'
and memname='STNDSTANDARDIZED_0000'
and( lower(name) not like '%_ciev_all' and lower(name) not like '%_csev_all' and lower(name) not like 'default%' and lower(name) not in ('period', 'cid', 'app_char_marital_status', 'app_char_job_code',
'app_char_home_status', 'app_char_city', 'app_char_cars', 'act_cus_loan_number')));
    
quit; 


%macro rekordy2(input);
ods results off;
%let N_NAMES = %sysfunc(countw(&amp;amp;NAMES.));&amp;nbsp;%do i=1 %to &amp;amp;N_NAMES;
%let zmienna=%scan(&amp;amp;NAMES, &amp;amp;i,%STR( ));

data zbiory.outlier&amp;amp;zmienna.;
set &amp;amp;input.;
if  &amp;amp;zmienna. &amp;gt;3 or &amp;amp;zmienna.  &amp;lt;-3 then &amp;amp;zmienna. =1;
else &amp;amp;zmienna. =0;
keep period act_age; 
%end;
ods results on;
%mend;
%rekordy2(STNDSTANDARDIZED_0000);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it's doesn't work :(.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;thank you in advance for your help&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 15 Jan 2023 08:33:49 GMT</pubDate>
    <dc:creator>Anastasija98</dc:creator>
    <dc:date>2023-01-15T08:33:49Z</dc:date>
    <item>
      <title>Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853908#M337502</link>
      <description>&lt;P&gt;Hello SAS Buddies &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Could you be so polite and help me with small issue? I try to make a new dataset for every columns from my basic dataset. It's my basic dataset with Standardize Data and I would like to find outlier for every columns (like make a flag).&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="325304895_577150883828567_1972157714311734525_n.png" style="width: 895px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79414i3241671DDAB52FD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="325304895_577150883828567_1972157714311734525_n.png" alt="325304895_577150883828567_1972157714311734525_n.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have someting like it;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="321638846_1167921607426705_4573772748608195385_n.png" style="width: 487px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/79413iAD8F8247BEC5D75D/image-size/large?v=v2&amp;amp;px=999" role="button" title="321638846_1167921607426705_4573772748608195385_n.png" alt="321638846_1167921607426705_4573772748608195385_n.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried do it with below code;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;
create table zbiory.name as 
    select NAME
    into     :NAMES separated by ' ' 
    from (select name from dictionary.columns
where libname = 'WORK'
and memname='STNDSTANDARDIZED_0000'
and( lower(name) not like '%_ciev_all' and lower(name) not like '%_csev_all' and lower(name) not like 'default%' and lower(name) not in ('period', 'cid', 'app_char_marital_status', 'app_char_job_code',
'app_char_home_status', 'app_char_city', 'app_char_cars', 'act_cus_loan_number')));
    
quit; 


%macro rekordy2(input);
ods results off;
%let N_NAMES = %sysfunc(countw(&amp;amp;NAMES.));&amp;nbsp;%do i=1 %to &amp;amp;N_NAMES;
%let zmienna=%scan(&amp;amp;NAMES, &amp;amp;i,%STR( ));

data zbiory.outlier&amp;amp;zmienna.;
set &amp;amp;input.;
if  &amp;amp;zmienna. &amp;gt;3 or &amp;amp;zmienna.  &amp;lt;-3 then &amp;amp;zmienna. =1;
else &amp;amp;zmienna. =0;
keep period act_age; 
%end;
ods results on;
%mend;
%rekordy2(STNDSTANDARDIZED_0000);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But it's doesn't work :(.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;thank you in advance for your help&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2023 08:33:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853908#M337502</guid>
      <dc:creator>Anastasija98</dc:creator>
      <dc:date>2023-01-15T08:33:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853910#M337504</link>
      <description>„Doesn‘t work“ tells us near to NOTHING.&lt;BR /&gt;Describe clearly where the result does not meet your expectations, and post the log by copy/pasting it into a window opened with the &amp;lt;/&amp;gt; button.</description>
      <pubDate>Sun, 15 Jan 2023 09:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853910#M337504</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-01-15T09:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853911#M337505</link>
      <description />
      <pubDate>Sun, 15 Jan 2023 09:32:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853911#M337505</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2023-01-15T09:32:50Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853914#M337506</link>
      <description>&lt;P&gt;When I run macro;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sql;

    select NAME
    into     :NAMES separated by ' ' 
    from (select name from dictionary.columns
where libname = 'WORK'
and memname='STNDSTANDARDIZED_0000'
and( lower(name) not like '%_ciev_all' and lower(name) not like '%_csev_all' and lower(name) not like 'default%' and lower(name) not in ('period', 'cid', 'app_char_marital_status', 'app_char_job_code',
'app_char_home_status', 'app_char_city', 'app_char_cars', 'act_cus_loan_number')));
    
quit; 

/*Z DATA SETEP*/
/*?*/
/***************tabele z rekordami****************/
%macro rekordy2(input);

%let N_NAMES = %sysfunc(countw(&amp;amp;NAMES.));&amp;nbsp;

%do i=1 %to &amp;amp;N_NAMES;
%let zmienna=%scan(&amp;amp;NAMES, &amp;amp;i,%STR( ));

data zbiory.outlier&amp;amp;zmienna.;
set &amp;amp;input.;
if  &amp;amp;zmienna. &amp;gt;3 or &amp;amp;zmienna.  &amp;lt;-3 then &amp;amp;zmienna. =1;
else &amp;amp;zmienna. =0;
keep period &amp;amp;zmienna.; 
%end;
%mend;
&amp;nbsp;

%rekordy2(STNDSTANDARDIZED_0000);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I have this error;&lt;/P&gt;&lt;P&gt;42 &amp;nbsp;&lt;BR /&gt;_&lt;BR /&gt;180&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: Line generated by the invoked macro "REKORDY2".&lt;BR /&gt;42 data zbiory.outlier&amp;amp;zmienna.; set &amp;amp;input.; if &amp;amp;zmienna. &amp;gt;3 or &amp;amp;zmienna. &amp;lt;-3 then &amp;amp;zmienna. =1; else &amp;amp;zmienna. =0;&lt;BR /&gt;___&lt;BR /&gt;180&lt;BR /&gt;42 ! keep period &amp;amp;zmienna.;&lt;BR /&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For some variables macro works but some no and I don't undestand where there's bug&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2023 09:57:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853914#M337506</guid>
      <dc:creator>Anastasija98</dc:creator>
      <dc:date>2023-01-15T09:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853915#M337507</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/425736"&gt;@Anastasija98&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;sorry, hit the wrong button.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You aren't making things easy. It is a bit difficult to answer your question when you don't provide input data in a usable form and don't explain what you are trying to achieve.&lt;/P&gt;
&lt;P&gt;By reading to decipher your code, it seems that you want a boolean flag set for each numeric variable in your input, and set it to 1 if the absolute value is &amp;gt; 3 or else 0. IF this is the case (we cannot know, because we don't know all variables in input), there might be a simpler solution. The following code computes all the boolean variables and adds them to the output data set. Then you have them all in one place and can later select what you want for a given purpose.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  ID = '12345'; var_1 = 0.234; var_2 = -4; var_3 = -2.9; var_4 = 25;
run;

data _null_; set have (obs=1);
  array vlist _numeric_;
  length out_list $200;
  retain out_list;
  do i = 1 to dim(vlist);
    out_list = catx(' ', out_list, catt('out_',vname(vlist{i})));
  end;
  call symputx('out_list', out_list);
run;
%put &amp;amp;=outline_list;

data want (drop=i); set have;
  array vlist _numeric_;
  array outline_list &amp;amp;out_list;
  do i = 1 to dim(vlist);
    if abs(vlist{i}) &amp;gt; 3 then outline_list{i} = 1; 
    else outline_list{i} = 0;
  end;
run;
    &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2023 10:12:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853915#M337507</guid>
      <dc:creator>ErikLund_Jensen</dc:creator>
      <dc:date>2023-01-15T10:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853916#M337508</link>
      <description>&lt;P&gt;Show us the ENTIRE log, not just the error messages. Since this involves a macro, please run this command&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then edit the macro to loop once&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and re-run the macro and then copy and paste the ENTIRE log into the window that appears when you click on the &amp;lt;/&amp;gt; icon&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PaigeMiller_0-1663012019648.png" style="width: 859px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75161i0E71B1489A6C9839/image-size/large?v=v2&amp;amp;px=999" role="button" title="PaigeMiller_0-1663012019648.png" alt="PaigeMiller_0-1663012019648.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2023 11:04:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853916#M337508</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-01-15T11:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Macro for every columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853932#M337516</link>
      <description>&lt;P&gt;Did you perhaps accidentally set the VALIDVARNAME option to ANY?&lt;/P&gt;
&lt;P&gt;If so then you need to modify the code to allow for names that have spaces in them by using the NLITERAL() function when building this list.&amp;nbsp; Which means you should&amp;nbsp;use something other than space as the delimiter.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
select nliteral(NAME) into :NAMES separated by '|' 
...
%sysfunc(countw(&amp;amp;names,|))
...
%scan(&amp;amp;names,&amp;amp;i,|)
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you do want to use space as the delimiter than add the Q modifier to the %SCAN() and COUNTW() function calls.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
select nliteral(NAME) into :NAMES separated by ' ' 
...
%sysfunc(countw(&amp;amp;names,%str( ),q))
...
%scan(&amp;amp;names,&amp;amp;i,%str( ),q)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Jan 2023 19:22:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-for-every-columns/m-p/853932#M337516</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-01-15T19:22:53Z</dc:date>
    </item>
  </channel>
</rss>

