<?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 format large dataset? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501027#M133532</link>
    <description>What does not well arranged mean? Which of the variable listing options in the link provided did you try that didn’t work - please show your code as well.</description>
    <pubDate>Wed, 03 Oct 2018 04:23:08 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-10-03T04:23:08Z</dc:date>
    <item>
      <title>How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501019#M133527</link>
      <description>&lt;P&gt;I have a data set below. I want to format all categorical variables that have numbers (variables starting with "i" are all indicators (1="yes" and 0="no")). The picture below only shows six of those variables (idem, ipsychrx, icnsrx, incoven, iatypical and ibenzo). But I have 47 of them in total. How to I format them without necessarily creating proc format for each variable? And how do I create a new four level variable type from the variables 'iconven' and 'iatypical' that have values 0="neither", 1="conventional", 2="atypical only", 3="both"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-10-02 at 11.03.27 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23736i033ADD57A42775B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-10-02 at 11.03.27 PM.png" alt="Screen Shot 2018-10-02 at 11.03.27 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 03:38:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501019#M133527</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-03T03:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501020#M133528</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226541"&gt;@JUMMY&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a data set below. I want to format all categorical variables that have numbers (variables starting with "i" are all indicators (1="yes" and 0="no")). The picture below only shows six of those variables (idem, ipsychrx, icnsrx, incoven, iatypical and ibenzo). But I have 47 of them in total. How to I format them without necessarily creating proc format for each variable? And how do I create a new four level variable type from the variables 'iconven' and 'iatypical' that have values 0="neither", 1="conventional", 2="atypical only", 3="both"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2018-10-02 at 11.03.27 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/23736i033ADD57A42775B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2018-10-02 at 11.03.27 PM.png" alt="Screen Shot 2018-10-02 at 11.03.27 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Applying a format is different than creating a format. You can create a format once and apply that format to multiple variables in various ways.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To apply the format, you can use a variable list with the format.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Format iFIRSTVAR —iLastVar yesNofmt.;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Different ways of referencing a variable list.&amp;nbsp;&lt;/P&gt;
&lt;P&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;Please post data as text not images, to work with your data we’d have to type it out.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 03:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501020#M133528</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-03T03:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501021#M133529</link>
      <description>But the data set is not well arranged. So how do I go about it?</description>
      <pubDate>Wed, 03 Oct 2018 03:58:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501021#M133529</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-03T03:58:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501027#M133532</link>
      <description>What does not well arranged mean? Which of the variable listing options in the link provided did you try that didn’t work - please show your code as well.</description>
      <pubDate>Wed, 03 Oct 2018 04:23:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501027#M133532</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-03T04:23:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501037#M133539</link>
      <description>&lt;P&gt;It is NEVER proper to post data as a picture. Pictures do not reveal&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;variable types&lt;/LI&gt;
&lt;LI&gt;length of variables&lt;/LI&gt;
&lt;LI&gt;assigned formats&lt;/LI&gt;
&lt;LI&gt;raw values that underlie those formats&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;and they force anyone who wants to help you to type data off the screenshot, which is&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;tedious&lt;/LI&gt;
&lt;LI&gt;opens possibilities for mistakes&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Please post example data as a data step with datalines. My second footnote leads you to a macro which does the conversion from a dataset to a data step automatically. See my third footnote for advice on posting code in a reliable manner.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 06:58:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501037#M133539</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-10-03T06:58:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501093#M133565</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/226541"&gt;@JUMMY&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As has been mentioned, variable lists make it easy to associate a format with several variables. In your case the list &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;i:&lt;/FONT&gt;&lt;/STRONG&gt; using the common prefix "i" and the colon operator is ideal. How could there be a shorter way to refer to all variables whose names start with "i"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you define your formats (with the FORMAT &lt;EM&gt;procedure&lt;/EM&gt;) once ...&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value yesno
0='no'
1='yes'
.=' ';

value type
0='neither'
1='conventional'
2='atypical only'
3='both'
.=' ';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;... and then (if desired) associate them with variables using the FORMAT &lt;EM&gt;statement&lt;/EM&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
if n(iatypical, iconven)=2 then type=2*iatypical+iconven;
format i: yesno. type type.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I put the FORMAT statement into a data step only because a new variable, TYPE, had to be created (not to be confused with the format of the same name). Otherwise, I would have used PROC DATASETS (with a MODIFY statement and the above FORMAT statement) to avoid unnecessary reading and writing of data if only changes to a dataset's "header information" (such as formats and labels) had been required.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 11:35:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501093#M133565</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-03T11:35:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501126#M133581</link>
      <description>@FreelanceReinhard, there are four original cost variables: stpamt, sfpamt, sppamt and srpamt (some are not shown in the data above). How do I use arrays and do loops to create two sets of transformed cost variables, the natural log of each of the costs and the square root of each the costs?</description>
      <pubDate>Wed, 03 Oct 2018 13:19:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501126#M133581</guid>
      <dc:creator>JUMMY</dc:creator>
      <dc:date>2018-10-03T13:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to format large dataset?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501151#M133591</link>
      <description>&lt;P&gt;Just insert a few lines into the datastep that I suggested:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
array a[*]   stpamt   sfpamt   sppamt   srpamt;
array l[*] l_stpamt l_sfpamt l_sppamt l_srpamt;
array r[*] r_stpamt r_sfpamt r_sppamt r_srpamt;
do j=1 to dim(a);
  if a[j]&amp;gt; 0 then l[j]=log(a[j]);
  if a[j]&amp;gt;=0 then r[j]=sqrt(a[j]);
end;
if n(iatypical, iconven)=2 then type=2*iatypical+iconven;
format i: yesno. type type.;
drop j;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This assumes that there are no variables &lt;FONT face="courier new,courier"&gt;a&lt;/FONT&gt;,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;j&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;l&lt;/FONT&gt; or &lt;FONT face="courier new,courier"&gt;r&lt;/FONT&gt; in dataset HAVE and also none of the&amp;nbsp;eight newly created variables &lt;FONT face="courier new,courier"&gt;l_stpamt&lt;/FONT&gt;, ..., &lt;FONT face="courier new,courier"&gt;r_srpamt&lt;/FONT&gt;. If this assumption is violated, please use different names to avoid name conflicts.&lt;/P&gt;</description>
      <pubDate>Wed, 03 Oct 2018 14:18:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-format-large-dataset/m-p/501151#M133591</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-10-03T14:18:23Z</dc:date>
    </item>
  </channel>
</rss>

