<?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 format to all numeric values all at once in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940312#M369090</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* data you have */
data WORK.test;
  array allNumeric[50] (1:50);
  array allCaracter[50] $ (50*"X");
  do i=1 to 10;
    output;
  end;
  format _numeric_ roman.;
run;
title "Before";
proc print data=work.test;
run;


/* code to do */
proc datasets lib=WORK noprint;
  modify test;
    format _numeric_ best32.;
  run;
quit;

title "After";
proc print data=work.test;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 21 Aug 2024 14:43:59 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2024-08-21T14:43:59Z</dc:date>
    <item>
      <title>How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940308#M369089</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I have a over 50 numeric variables and and I like to apply FORMAT to all at once (eg: Best32.). Is there a way to apply format to all numeric values without writing all variables in the script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 14:35:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940308#M369089</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2024-08-21T14:35:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940312#M369090</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* data you have */
data WORK.test;
  array allNumeric[50] (1:50);
  array allCaracter[50] $ (50*"X");
  do i=1 to 10;
    output;
  end;
  format _numeric_ roman.;
run;
title "Before";
proc print data=work.test;
run;


/* code to do */
proc datasets lib=WORK noprint;
  modify test;
    format _numeric_ best32.;
  run;
quit;

title "After";
proc print data=work.test;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Aug 2024 14:43:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940312#M369090</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-08-21T14:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940323#M369093</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;I have a over 50 numeric variables and and I like to apply FORMAT to all at once (eg: Best32.). Is there a way to apply format to all numeric values without writing all variables in the script?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Mike&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc datasets will do that. The first data step copies a set you should have available to test code with and not mess up the original.&lt;/P&gt;
&lt;PRE&gt;data work.cars;
   set sashelp.cars;
run;

proc datasets library=work;
   modify cars;
   format _numeric_ best32.;
   run;
quit;

/* examine the results*/
proc contents data=work.cars;
run;&lt;/PRE&gt;
&lt;P&gt;Proc datasets does this by modifying the header information in the data set and does not have to read the actual observations. So the time to execute doesn't vary much if the data set has 10 observations or 10 billion.&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 15:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940323#M369093</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-21T15:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940324#M369094</link>
      <description>Key idea, _numeric_ refers to all numeric variable and _character_ refers to all character variable. _all_ refers to all variables.</description>
      <pubDate>Wed, 21 Aug 2024 15:12:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940324#M369094</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-08-21T15:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940348#M369101</link>
      <description>&lt;P&gt;Thanks Ballardw. Your solution works for me, but I have a date field and _numeric_ function is converting the date field to numeric as well. Any solution to that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 17:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940348#M369101</guid>
      <dc:creator>mlogan</dc:creator>
      <dc:date>2024-08-21T17:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940360#M369108</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/35631"&gt;@mlogan&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks Ballardw. Your solution works for me, but I have a date field and _numeric_ function is converting the date field to numeric as well. Any solution to that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Provide a separate entry for your other variable(s) after the _numeric_. Sort of a "last one wins". An example using a data set with a date variable you should have.&lt;/P&gt;
&lt;PRE&gt;data work.stocks;
   set sashelp.stocks (obs=50);
run;

proc datasets library=work;
   modify stocks;
      format _numeric_ best32.
             date date9.
      ;
   run;
quit;&lt;/PRE&gt;
&lt;P&gt;This is actually not uncommon with many statements in procedures. If you provide two different format statements for the same variable the last one is typically the result. If you use two Xaxis statements in Proc Sgplot the last is the one in effect, not the combined elements of two statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe not all, but generally the way to bet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 18:02:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940360#M369108</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-21T18:02:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to apply format to all numeric values all at once</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940385#M369116</link>
      <description>&lt;P&gt;If the variables have an order you can list them to include the numeric variables only in the list excluding date. If date is in the middle you could split it into two lists.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use the order approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data heart;
set sashelp.heart;
format AgeCHDdiag - NUMERIC - systolic 8.4;
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, 21 Aug 2024 19:31:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-apply-format-to-all-numeric-values-all-at-once/m-p/940385#M369116</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2024-08-21T19:31:10Z</dc:date>
    </item>
  </channel>
</rss>

