<?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: Trouble performin operation on the colums starting with specific characters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903624#M357044</link>
    <description>&lt;P&gt;You haven't really said what you want to do to these columns, so I can't give you specific instructions, but perhaps a DATA step ARRAY might be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array x id_03_:;
    do i=1 to dim(x);
         x(i)=x(i)+1; /* Do something to these columns; in this example I add 1 to the value in each column */
    end;
    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 17 Nov 2023 11:12:57 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-11-17T11:12:57Z</dc:date>
    <item>
      <title>Trouble performin operation on the colums starting with specific characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903617#M357042</link>
      <description>&lt;P&gt;Hallo,&lt;BR /&gt;I have a table wich contains 50 colums, 30 of which have a name which start with "ID_03_".&lt;BR /&gt;I would like to perform some operations only on the columns with these initial characters.&lt;BR /&gt;Ideally, the program wold scan the names of the colums and do&amp;nbsp;&lt;BR /&gt;"if the name starst then "ID_03_" perform something, otherwise skip to the next column".&lt;BR /&gt;&lt;BR /&gt;is it possibile?&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 10:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903617#M357042</guid>
      <dc:creator>cieffegi</dc:creator>
      <dc:date>2023-11-17T10:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble performin operation on the colums starting with specific characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903624#M357044</link>
      <description>&lt;P&gt;You haven't really said what you want to do to these columns, so I can't give you specific instructions, but perhaps a DATA step ARRAY might be useful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    array x id_03_:;
    do i=1 to dim(x);
         x(i)=x(i)+1; /* Do something to these columns; in this example I add 1 to the value in each column */
    end;
    drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Nov 2023 11:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903624#M357044</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-11-17T11:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: Trouble performin operation on the colums starting with specific characters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903716#M357079</link>
      <description>&lt;DIV&gt;/* Using sashelp.mon111 which contains prefixed varnames.&amp;nbsp; &amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;All variables are numeric so example multiplies original by 2 .&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;Select S6 as prefix where mon111 has 10 S6 variables. */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;proc contents data=sashelp.mon111;&amp;nbsp; /* explore table */&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;proc sql;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /* Create macro variable series of vars */&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;select name&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; into :var1-&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; from sashelp.vcolumn&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; where libname='SASHELP' and memname='MON111' and name like 'S6%';&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;quit;&lt;/DIV&gt;
&lt;DIV&gt;%put NOTE: &amp;amp;=sqlobs;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;%macro x;&lt;/DIV&gt;
&lt;DIV&gt;data work.test;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;set sashelp.mon111;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;%do i = 1 %to &amp;amp;sqlobs;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;new_&amp;amp;&amp;amp;var&amp;amp;i = &amp;amp;&amp;amp;var&amp;amp;i * 2;&amp;nbsp; /* e.g., create a new variable twice value of original */&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;%end;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;proc print;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp;var %do i=1 %to &amp;amp;sqlobs;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp;var&amp;amp;i new_&amp;amp;&amp;amp;var&amp;amp;i&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;%end;;&lt;/DIV&gt;
&lt;DIV&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;%mend x;&lt;/DIV&gt;
&lt;DIV&gt;%x&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Partial output, 3 of 10 variable pairs&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TSR_0-1700247105752.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/89974iE7C2721FC1E758D6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TSR_0-1700247105752.png" alt="TSR_0-1700247105752.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Nov 2023 18:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trouble-performin-operation-on-the-colums-starting-with-specific/m-p/903716#M357079</guid>
      <dc:creator>TSR</dc:creator>
      <dc:date>2023-11-17T18:55:31Z</dc:date>
    </item>
  </channel>
</rss>

