<?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: Wildcard? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740846#M80550</link>
    <description>&lt;P&gt;If you have a consistent prefix then the key is how you declare your array statement using one of the shortcut methods.&amp;nbsp; If they all have a consistent prefix for example, this would work. As long as the prefix is used only for that variable and consistently you're good to go.&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 _myvars(*) var_prefix: ;

do i=1 to dim(_myvars);
if _myvars(I) = "Other" then _myvars(i) = "Oth";
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>Wed, 12 May 2021 16:08:47 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-05-12T16:08:47Z</dc:date>
    <item>
      <title>Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740823#M80542</link>
      <description>&lt;P&gt;I have variables &lt;EM&gt;var1&lt;/EM&gt; - &lt;EM&gt;var28&lt;/EM&gt;; there are other variables in the dataset too, like name, race, sex, etc. For the &lt;EM&gt;var1&lt;/EM&gt;-&lt;EM&gt;var28&lt;/EM&gt; variables, I want to replace any value "other" with "oth." Without listing out all 28 variables, is there a way to do this? (I don't want to list out the variables because (1) there are too many and it is does not seem concise and (2) because this code is automated and every year, we have a different number of these variables--e.g., next year, we may have var1-var35.) In my head I want to do something like the following, but don't know how to execute it in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if var* = "other" then var* = "oth"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:15:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740823#M80542</guid>
      <dc:creator>raivester</dc:creator>
      <dc:date>2021-05-12T15:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740826#M80543</link>
      <description>&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a tutorial on using Arrays in SAS&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-arrays/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-arrays/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;_numeric_ : all numeric variables
_character_ : all character variables
_all_  : all variables
prefix1 - prefix# : all variables with the same prefix assuming they're numbered
prefix:  : all variables that start with prefix
firstVar -- lastVar : variables based on location between first and last variable, including the first and last. 
first-numeric-lastVar : variables that are numeric based on location between first and last variable&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 May 2021 15:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740826#M80543</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T15:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740831#M80545</link>
      <description>&lt;P&gt;This concept is referred to as an operation using an array.&amp;nbsp; Although we can use some SAS wildcard syntax.&amp;nbsp; DO OVER works in SAS, but it is not documented, but there are other documented ways to do this with do loops.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data;
  length var1-var3 $5;
  array var var1-var3 ;
  do over var;
    var="other";
  end;
  output;
  do over var;
    if var="other"
      then var="oth";
  end;
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:29:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740831#M80545</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-05-12T15:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740832#M80546</link>
      <description>DO OVER was deprecated (SAS V7 20+ years ago) but its also being brought back within CAS. &lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmcdc/8.11/proccas/n1enf8paum6q19n1cascbj8z5kpc.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmcdc/8.11/proccas/n1enf8paum6q19n1cascbj8z5kpc.htm&lt;/A&gt;</description>
      <pubDate>Wed, 12 May 2021 15:31:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740832#M80546</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T15:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740835#M80547</link>
      <description>&lt;P&gt;I say, using DO OVER is the best example we can give keeping in the spirit of using wildcards; it is something done to do more with less syntax.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 15:42:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740835#M80547</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-05-12T15:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740842#M80549</link>
      <description>&lt;P&gt;Fix your read so the desired values are read as needed to begin with. A data step and a custom informat means you don't have to "fix" anything "next year".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc format;
invalue $fixoth (upcase default=20)
'OTHER' = 'oth.'
;

data example;
  informat var1 - var3 $fixoth.;
  input var1 - var3;
datalines;
other sometext thattext
this  that     those
that  this     other
other other    other
;&lt;/PRE&gt;
&lt;P&gt;There may be some other details about actual length of the invalue/ informat when used but the only change needed next time would be the INFORMAT variable list.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that my specific example will work with text like: Other OTHER other oTHer and other changes in capitalization.&lt;/P&gt;</description>
      <pubDate>Wed, 12 May 2021 16:00:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740842#M80549</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-05-12T16:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Wildcard?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740846#M80550</link>
      <description>&lt;P&gt;If you have a consistent prefix then the key is how you declare your array statement using one of the shortcut methods.&amp;nbsp; If they all have a consistent prefix for example, this would work. As long as the prefix is used only for that variable and consistently you're good to go.&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 _myvars(*) var_prefix: ;

do i=1 to dim(_myvars);
if _myvars(I) = "Other" then _myvars(i) = "Oth";
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>Wed, 12 May 2021 16:08:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Wildcard/m-p/740846#M80550</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-12T16:08:47Z</dc:date>
    </item>
  </channel>
</rss>

