<?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 simplify the PUT procedure? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367216#M87396</link>
    <description>&lt;P&gt;There are variations available on the ARRAY statement (you might have some studying to do). &amp;nbsp;But you have to type a 7 somewhere. &amp;nbsp;This variation would be possible:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array N {*} N1-N7;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 03:04:08 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-15T03:04:08Z</dc:date>
    <item>
      <title>How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367200#M87388</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wondering if there is a way to avoid writing such long 'PUT" statement below? &amp;nbsp;Also, I list another question below. &amp;nbsp;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test1;&lt;BR /&gt;input N1-N7;&lt;BR /&gt;cards;&lt;BR /&gt;1 1 1 1 1 1 1&lt;BR /&gt;1 0 1 1 0 0 1&lt;BR /&gt;0 0 0 0 1 1 1&lt;BR /&gt;1 1 1 1 1 1 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc means data=test1;&lt;BR /&gt;var _numeric_;&lt;BR /&gt;output out=test2 sum=n1-n7; /*Is there another way to list from N1 to N7 so that no need to type? */&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data test3;&lt;BR /&gt;set test2 (keep=N1-N7 obs=1);&lt;BR /&gt;cnt1=put(n1,2.);&lt;BR /&gt;cnt2=put(n2,2.);&lt;BR /&gt;cnt3=put(n3,2.);&lt;BR /&gt;cnt4=put(n4,2.);&lt;BR /&gt;cnt5=put(n5,2.);&lt;BR /&gt;cnt6=put(n6,2.);&lt;BR /&gt;cnt7=put(n7,2.); /*Is there an anther way to do this instead of listing all of numbers? I wish I don't need to count.*/&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 01:05:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367200#M87388</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-15T01:05:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367205#M87390</link>
      <description>&lt;P&gt;Q1. When PROC MEANS calculates just one type of statistic, such as the SUM, you can specify:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;output out=test2 sum=;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;By skipping the naming of the variables, this tells SAS to re-use the original names. &amp;nbsp;So TEST2 contains the original variable names, but holding the SUM of the original values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Q2. When you process a set of variables using the same logic, you can use arrays. &amp;nbsp;In this case, since you only have 7 variables, the replacement code is nearly as long as the original:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data&amp;nbsp;test3;&lt;BR /&gt;set test2 (keep=N1-N7 obs=1);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;array N {7};&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;array cnt&amp;nbsp;{7} $ 2;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;do _n_=1 to 7;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;cnt{_n_} = put(N{_n_}, 2.);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;So it's more complex (you will need to learn about arrays), and nearly as long as the original. &amp;nbsp;But if you had 300 variables instead of 7, the length of the program wouldn't change. &amp;nbsp;And it doesn't save you counting. &amp;nbsp;You have to add the "7" as part of the ARRAY statement.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 01:45:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367205#M87390</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-15T01:45:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367210#M87392</link>
      <description>&lt;P&gt;Why are you converting all your numbers to character variables?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 02:34:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367210#M87392</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T02:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367214#M87395</link>
      <description>&lt;P&gt;I'm wondering, is there a way not typing 7 after&amp;nbsp;array?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;array N {7};&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;array cnt&amp;nbsp;{7} $ 2;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 02:49:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367214#M87395</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-15T02:49:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367216#M87396</link>
      <description>&lt;P&gt;There are variations available on the ARRAY statement (you might have some studying to do). &amp;nbsp;But you have to type a 7 somewhere. &amp;nbsp;This variation would be possible:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array N {*} N1-N7;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 03:04:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367216#M87396</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-15T03:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367232#M87401</link>
      <description>&lt;P&gt;You can extract a count of variables from dictionary.columns.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 06:15:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367232#M87401</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-15T06:15:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to simplify the PUT procedure?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367318#M87429</link>
      <description>&lt;P&gt;Thanks, I will look for the information of dictionary.columns.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 11:27:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-simplify-the-PUT-procedure/m-p/367318#M87429</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-06-15T11:27:39Z</dc:date>
    </item>
  </channel>
</rss>

