<?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: How to apply the same format to multiple variables? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783152#M249679</link>
    <description>&lt;P&gt;At first i was thinking about making a variable list as you said. I realized however after Mr PaigeMiller's answer that i can indeed use the prefix list feature that you also mentioned.&lt;BR /&gt;So all i had to do was ​&lt;/P&gt;&lt;PRE&gt;format ia1_1-ia1_26 format_test.;&lt;/PRE&gt;&lt;P&gt;Thank you for taking the time to clarify these methods though.&lt;/P&gt;</description>
    <pubDate>Tue, 30 Nov 2021 14:52:36 GMT</pubDate>
    <dc:creator>Traian</dc:creator>
    <dc:date>2021-11-30T14:52:36Z</dc:date>
    <item>
      <title>How to apply the same format to multiple variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783138#M249675</link>
      <description>&lt;P&gt;I have around 26 variables ranging from ia1_1, ia1_2, ia_3 ... ia_26. I would like to apply a format to them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data test_2;
set test_1;
Format ia1_1 format_test.;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i do this, i can apply it to one variable. I was wondering if there was a quick way to somehow apply it to all of these instead of manually doing it for each one. Note: these are not the only variables in the table. I have little experience in SAS and not knowing how to optimize simple things drives me crazy.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 14:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783138#M249675</guid>
      <dc:creator>Traian</dc:creator>
      <dc:date>2021-11-30T14:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the same format to multiple variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783139#M249676</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format ia1_1 ia1_2 ia_3 ... ia_26 format_test.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Where the ... (triple dots) indicate you have to type in the variable names you want to have this format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please note that your variables don't form a pattern of variable names with consecutive numbers, if it did, you could do something like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;format ia_1-ia_26 format_test.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 14:11:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783139#M249676</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-11-30T14:11:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the same format to multiple variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783148#M249678</link>
      <description>&lt;P&gt;You can list as many variables in a single FORMAT statement as you want.&amp;nbsp; If you want to apply the same format to multiple variables you only need to list format specification once, right after the list of names.&amp;nbsp; You can apply different formats to different variables in the same FORMAT statement by inlcluding as many variable_list format_specification pairs as you need.&amp;nbsp; Note if you want to REMOVE any attached format then list the variables without any format specification. That one obviously has to be the list list/format combination in the FORMAT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use variable lists to reduce the amount of typing.&amp;nbsp; If you use sequential numeric suffixes.&amp;nbsp; var1-var23&lt;/P&gt;
&lt;P&gt;Or if you know their order in the "data vector" (their order in the dataset being written) you can use positional variable list. firstvar -- lastvar.&amp;nbsp; &amp;nbsp;You also specify numeric, character or all variables by using _numeric_, _character_ or _all_.&amp;nbsp; And you can limit positional lists to one type: firstvar-numeric-lastvar.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And more recently they added name prefix lists.&amp;nbsp; So all variables that start with a constant set of characters.&amp;nbsp; Like in your case you might be able to use ia:&amp;nbsp; to include all of those variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can include more than one statement in a data step.&amp;nbsp; So even if you did not want to make one long FORMAT statement you could just include many shorter ones.&amp;nbsp; Or other things you want to do in that step, like perform calculations or rename variables or attach labels to variables, etc.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 14:44:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783148#M249678</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-11-30T14:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply the same format to multiple variables?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783152#M249679</link>
      <description>&lt;P&gt;At first i was thinking about making a variable list as you said. I realized however after Mr PaigeMiller's answer that i can indeed use the prefix list feature that you also mentioned.&lt;BR /&gt;So all i had to do was ​&lt;/P&gt;&lt;PRE&gt;format ia1_1-ia1_26 format_test.;&lt;/PRE&gt;&lt;P&gt;Thank you for taking the time to clarify these methods though.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Nov 2021 14:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-the-same-format-to-multiple-variables/m-p/783152#M249679</guid>
      <dc:creator>Traian</dc:creator>
      <dc:date>2021-11-30T14:52:36Z</dc:date>
    </item>
  </channel>
</rss>

