<?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: Looping through a data set with cluster names and generate observations for each name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391143#M93900</link>
    <description>&lt;P&gt;Well, SAS is different than R, so although you'll probably get to where you're getting with this method, I'd suggest you explain a bit more of what you're trying to do and we can suggest the optimal SAS method to accomplish this. SAS works more on PROCEDURES and something like PROC SURVEYSELECT may be what you're looking for rather than manually doing randomly simulating data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If you already had a data set another option is to use your data set as is. Let's say you had the SASHELP.CLASS data set and wanted to create 50 random variables for each person, it would loook like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set sashelp.class;

    do i=1 to 50;
        zv = rannor(0);
        output;
    end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161149"&gt;@mrer&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS Experts,&lt;/P&gt;
&lt;P&gt;I'm coming from the R world and have some troubles getting started with SAS at the moment.&lt;/P&gt;
&lt;P&gt;What I want to do:&lt;/P&gt;
&lt;P&gt;I have a data set with names of cluster and now I want to simlulate lets say 50 random numbers for each cluster. I already found out to do it without using the data set of cluster names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
   do ClusterID=1 to 100;
     DO i=1 TO 50; ZV=Rannor(0);
       output;
     end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But how do I do it now when I have the cluster names stored in a data set called clusterid with the variable name clustername?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Aug 2017 18:29:26 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-08-27T18:29:26Z</dc:date>
    <item>
      <title>Looping through a data set with cluster names and generate observations for each name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391139#M93897</link>
      <description>&lt;P&gt;Hello SAS Experts,&lt;/P&gt;&lt;P&gt;I'm coming from the R world and have some troubles getting started with SAS at the moment.&lt;/P&gt;&lt;P&gt;What I want to do:&lt;/P&gt;&lt;P&gt;I have a data set with names of cluster and now I want to simlulate lets say 50 random numbers for each cluster. I already found out to do it without using the data set of cluster names:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
   do ClusterID=1 to 100;
     DO i=1 TO 50; ZV=Rannor(0);
       output;
     end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But how do I do it now when I have the cluster names stored in a data set called clusterid with the variable name clustername?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 18:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391139#M93897</guid>
      <dc:creator>mrer</dc:creator>
      <dc:date>2017-08-27T18:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through a data set with cluster names and generate observations for each name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391143#M93900</link>
      <description>&lt;P&gt;Well, SAS is different than R, so although you'll probably get to where you're getting with this method, I'd suggest you explain a bit more of what you're trying to do and we can suggest the optimal SAS method to accomplish this. SAS works more on PROCEDURES and something like PROC SURVEYSELECT may be what you're looking for rather than manually doing randomly simulating data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;If you already had a data set another option is to use your data set as is. Let's say you had the SASHELP.CLASS data set and wanted to create 50 random variables for each person, it would loook like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set sashelp.class;

    do i=1 to 50;
        zv = rannor(0);
        output;
    end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/161149"&gt;@mrer&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello SAS Experts,&lt;/P&gt;
&lt;P&gt;I'm coming from the R world and have some troubles getting started with SAS at the moment.&lt;/P&gt;
&lt;P&gt;What I want to do:&lt;/P&gt;
&lt;P&gt;I have a data set with names of cluster and now I want to simlulate lets say 50 random numbers for each cluster. I already found out to do it without using the data set of cluster names:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data A;
   do ClusterID=1 to 100;
     DO i=1 TO 50; ZV=Rannor(0);
       output;
     end;
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But how do I do it now when I have the cluster names stored in a data set called clusterid with the variable name clustername?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Aug 2017 18:29:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391143#M93900</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-27T18:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looping through a data set with cluster names and generate observations for each name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391146#M93902</link>
      <description>that was an easy solution to my problem! Thank you very much!</description>
      <pubDate>Sun, 27 Aug 2017 19:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Looping-through-a-data-set-with-cluster-names-and-generate/m-p/391146#M93902</guid>
      <dc:creator>mrer</dc:creator>
      <dc:date>2017-08-27T19:10:06Z</dc:date>
    </item>
  </channel>
</rss>

