<?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: Fail to create tabel! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491232#M128772</link>
    <description>&lt;P&gt;I'm&amp;nbsp;not sure iI&amp;nbsp;understand&amp;nbsp;your reply?&lt;/P&gt;</description>
    <pubDate>Thu, 30 Aug 2018 13:38:22 GMT</pubDate>
    <dc:creator>Bruger</dc:creator>
    <dc:date>2018-08-30T13:38:22Z</dc:date>
    <item>
      <title>Fail to create tabel!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491150#M128739</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dear SAS user forum,&lt;/P&gt;&lt;P&gt;I came across the coding below that is very useful for my work. However, being a basic SAS user I am stuck with getting it to run on SAS 9.4. It seems like there is an issue in then of PROC IML where the table “random” is created.&lt;/P&gt;&lt;P&gt;I really hope that someone can sort this out for me&lt;/P&gt;&lt;P&gt;Kind regards&lt;/P&gt;&lt;P&gt;Hans&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DESCRIPTION&lt;BR /&gt;This code performs a multi-sample rarefaction. A dataset should consist of columns of values. Each column represents a sample and each row represents a different taxon (e.g., species). Each value represents a number of specimens representing that species. The number of rows with non-zero values represents sample diversity (taxon richness).&lt;BR /&gt;************************************************************************&lt;BR /&gt;SAS/IML Code written by Michal Kowalewski (Virginia Tech). This version last updated on March 15, 2010&lt;BR /&gt;************************************************************************&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* THE CODE BEGINS HERE;&lt;BR /&gt;OPTIONS linesize=256 pagesize=5000;&lt;BR /&gt;*--ENTER THESE MACROVARIABLES;&lt;BR /&gt;%let times=100; * - number of iterations to estimate confidence intervals;&lt;BR /&gt;*--RAREFACTION MACROVARIABLES;&lt;BR /&gt;%let sam=3; * - number of samples to be included in the analysis;&lt;BR /&gt;%let cut=3; * - standardized number of specimens per sample;&lt;BR /&gt;**********************************************************************;&lt;BR /&gt;*ENTER DATA&lt;BR /&gt;Note 1: Replace columns of numbers below with your data.&lt;BR /&gt;Note 2: You can simply copy-and-paste from Excel or other file containing your data.&lt;BR /&gt;Note 3: Modify in according to number of columns present in your dataset, the Loc1-Loc4 line (e.g., if your dataset is composed by 9 columns you should write: loc.1-loc.9).&lt;BR /&gt;Note 4: No missing values are allowed.&lt;BR /&gt;Note 5: Zero values are allowed.&lt;BR /&gt;Note 6: Only integers are allowed.&lt;BR /&gt;After completing all above steps you should be ready to run your data. Click on a running man on the SAS taskbar;&lt;BR /&gt;**********************************************************************;&lt;BR /&gt;Title1'Multi-sample rarefaction (SAS/IML)';&lt;BR /&gt;Title2'written by M. Kowalewski, 12/02/2004';&lt;BR /&gt;DATA new;&lt;BR /&gt;infile cards;&lt;BR /&gt;input loc1-loc4;&lt;BR /&gt;cards; * this data step will generate a sas-dataset called 'new';&lt;BR /&gt;1 3 17 5&lt;BR /&gt;2 4 0 4&lt;BR /&gt;5 5 0 143&lt;BR /&gt;6 6 0 0&lt;BR /&gt;17 7 45 0&lt;BR /&gt;42 4 8 12&lt;BR /&gt;6 2 32 0&lt;BR /&gt;0 9 194 0&lt;BR /&gt;32 0 4 0&lt;BR /&gt;0 17 1 1&lt;BR /&gt;1 0 0 2&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;PROC iml;&lt;BR /&gt;USE new;&lt;BR /&gt;READ all var _num_ into V;&lt;BR /&gt;START weight (X,Y);&lt;BR /&gt;k=ncol(X);&lt;BR /&gt;do i=1 to k;&lt;BR /&gt;s=X[1,i];&lt;BR /&gt;z=repeat(i,1,s);&lt;BR /&gt;zz=zz||z;&lt;BR /&gt;end;&lt;BR /&gt;zzz=t(zz);&lt;BR /&gt;Y=zzz;&lt;BR /&gt;FINISH weight;&lt;BR /&gt;START ranvec(in,frac,v_out);&lt;BR /&gt;k=nrow(in);&lt;BR /&gt;v_index=in;&lt;BR /&gt;do i=1 to k;&lt;BR /&gt;rand=floor((k-i+1)*ranuni(0) + 1);&lt;BR /&gt;v_ran=v_ran||v_index[rand];&lt;BR /&gt;v_index=remove(v_index,rand);&lt;BR /&gt;end;&lt;BR /&gt;temp=t(v_ran[,1:frac]);&lt;BR /&gt;v_out=temp;&lt;BR /&gt;FINISH ranvec;&lt;BR /&gt;START recr(X,frac,out);&lt;BR /&gt;Z=t(X);&lt;BR /&gt;k=ncol(Z);&lt;BR /&gt;run weight(Z,Y);&lt;BR /&gt;run ranvec(Y,frac,YY);&lt;BR /&gt;do i=1 to k;&lt;BR /&gt;a=i#(YY=i);&lt;BR /&gt;ab=sum(a)/i;&lt;BR /&gt;abun=abun//ab;&lt;BR /&gt;end;&lt;BR /&gt;*out=abun[loc(abun&amp;gt;0),];&lt;BR /&gt;out=abun;&lt;BR /&gt;FINISH recr;&lt;BR /&gt;START FINAL(X,out);&lt;BR /&gt;tot=&amp;amp;sam*&amp;amp;cut; *-total number of specimens that will be resampled;&lt;BR /&gt;Z=X; * - original data matrix (columns=samples) (rows=species);&lt;BR /&gt;index=t(1:ncol(Z));&lt;BR /&gt;do i=1 to &amp;amp;times;&lt;BR /&gt;run ranvec(index,&amp;amp;sam,sam);&lt;BR /&gt;rand=Z[,sam]; *-subset of samples, with number of samples defined by the macrovariable "sam";&lt;BR /&gt;do j=1 to ncol(rand);&lt;BR /&gt;a=rand[,j];&lt;BR /&gt;run recr(a,&amp;amp;cut,random);&lt;BR /&gt;b=b||random;&lt;BR /&gt;c=b[,+];&lt;BR /&gt;end;&lt;BR /&gt;b=shape(0,nrow(rand),1);&lt;BR /&gt;DivR=ncol(loc(c&amp;gt;0));&lt;BR /&gt;outt=DivR||&amp;amp;sam||&amp;amp;cut||tot||i;&lt;BR /&gt;output=output//outt;&lt;BR /&gt;end;&lt;BR /&gt;out=output;&lt;BR /&gt;FINISH FINAL;&lt;BR /&gt;RUN FINAL(V,out);&lt;BR /&gt;create random from out;&lt;BR /&gt;append from out;&lt;BR /&gt;close random;&lt;BR /&gt;QUIT;&lt;BR /&gt;run;&lt;BR /&gt;data report;&lt;BR /&gt;set random;&lt;BR /&gt;div=col1;&lt;BR /&gt;samples=col2;&lt;BR /&gt;sam_n=col3;&lt;BR /&gt;tot_n=col4;&lt;BR /&gt;iter=col5;&lt;BR /&gt;drop col1-col5;&lt;BR /&gt;proc print;&lt;BR /&gt;proc univariate noprint;&lt;BR /&gt;var div;&lt;BR /&gt;output out=final1 n=iter mean=diver std=std PCTLPRE=P_ PCTLPTS=2.5 25 75 97.5;&lt;BR /&gt;proc print;&lt;BR /&gt;run;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 09:54:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491150#M128739</guid>
      <dc:creator>Bruger</dc:creator>
      <dc:date>2018-08-30T09:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: Fail to create tabel!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491220#M128765</link>
      <description>&lt;P&gt;Calling&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:13:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491220#M128765</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-08-30T13:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Fail to create tabel!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491232#M128772</link>
      <description>&lt;P&gt;I'm&amp;nbsp;not sure iI&amp;nbsp;understand&amp;nbsp;your reply?&lt;/P&gt;</description>
      <pubDate>Thu, 30 Aug 2018 13:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491232#M128772</guid>
      <dc:creator>Bruger</dc:creator>
      <dc:date>2018-08-30T13:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Fail to create tabel!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491261#M128783</link>
      <description>&lt;P&gt;The code assumes that the data&amp;nbsp;are all positive counts. You have zeros in your data, which is why it is giving an error.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can get rid of the zeros in the data to see that the code works (replace them with 1).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The author of the code would be the best person to advise how to proceed. You can fix the problem by defining the WEIGHT module as follows, but I don't know if that change would preserve the behavior of the program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;   START weight (X,Y);
      k=ncol(X);

      do i=1 to k;
         s=X[1,i];
         if s&amp;gt;0 then do;
            z=repeat(i,1,s);
            zz=zz||z;
         end;
      end;

      zzz=t(zz);
      Y=zzz;
   FINISH weight;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Aug 2018 14:28:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Fail-to-create-tabel/m-p/491261#M128783</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-08-30T14:28:21Z</dc:date>
    </item>
  </channel>
</rss>

