<?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: Running Procs Within a Do Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34504#M6792</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as Art said. You can firstly make a macro to include these SQL proc print, then use call execute to loop this macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 26 Oct 2011 06:12:42 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-10-26T06:12:42Z</dc:date>
    <item>
      <title>Running Procs Within a Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34500#M6788</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey all, question:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a dataset of users and what I'm looking to do is look through all of them and create a series of reports by user.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So &lt;/P&gt;&lt;P&gt;table work.users&lt;/P&gt;&lt;P&gt;Username&lt;/P&gt;&lt;P&gt;----------------&lt;/P&gt;&lt;P&gt;Smith&lt;/P&gt;&lt;P&gt;Jones&lt;/P&gt;&lt;P&gt;Andrews&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My report code is&lt;/P&gt;&lt;P&gt;/***************************Set Dynamic Path and Filename***********************************/&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;ODS&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; tagsets.HTMLpanel &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;nogtitle&lt;/SPAN&gt;&amp;nbsp; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;Path&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;"&lt;A href="https://communities.sas.com/"&gt;\\myreports\[&lt;/A&gt;username]"&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;File&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; = &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: purple;"&gt;"[username].xls"&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;style&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;=minimal&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;/*************Create Dynamic Table for each User*************/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;proc sql;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;create table [username] as&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;select sales_id, sales_date, price from sales where name = '[username]';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;proc print data=[username];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;quit;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;ods&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;html&lt;/SPAN&gt; &lt;SPAN style="background-color: white; font-family: 'Courier New'; color: blue;"&gt;close&lt;/SPAN&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt;In my other programming experience I'd use a do while loop but I'm stuck as to how to do it in SAS.&amp;nbsp; Any help would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: white; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 20:42:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34500#M6788</guid>
      <dc:creator>JeffU</dc:creator>
      <dc:date>2011-10-25T20:42:54Z</dc:date>
    </item>
    <item>
      <title>Running Procs Within a Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34501#M6789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; If I understand what you want to do the easiest may be a BY group process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc sort data=Sales out=SortedSales;by username;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=SortedSales;&lt;/P&gt;&lt;P&gt;by username;&lt;/P&gt;&lt;P&gt;var sales_id sales_date price;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 21:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34501#M6789</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-10-25T21:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: Running Procs Within a Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34502#M6790</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you need to do it for all users or only a select users?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you looked at BY processing? Or Macro processing? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically theres a lot of ways to do it, I'd need more info to see what the best way to do it would be, but guessing you're going to go down the macro route if you want a file for each user. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See here for a basic idea:&lt;/P&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/default.htm"&gt;http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/default.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 21:09:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34502#M6790</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-10-25T21:09:45Z</dc:date>
    </item>
    <item>
      <title>Re: Running Procs Within a Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34503#M6791</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yet another way of doing it, but one which would accept the code basically how you have written it, is to submit the code within a datastep using call execute.&amp;nbsp; You can find an example of doing that in the following thread:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://communities.sas.com/message/101028#101028"&gt;http://communities.sas.com/message/101028#101028&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since SAS inherently loops through the records during a datastep, you don't need to get overly loopy.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Oct 2011 22:51:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34503#M6791</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-25T22:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: Running Procs Within a Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34504#M6792</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just as Art said. You can firstly make a macro to include these SQL proc print, then use call execute to loop this macro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 Oct 2011 06:12:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-Procs-Within-a-Do-Loop/m-p/34504#M6792</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-10-26T06:12:42Z</dc:date>
    </item>
  </channel>
</rss>

