<?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: lloop through a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69106#M15002</link>
    <description>You can't call SQL statements to run inside a datastep.&lt;BR /&gt;
&lt;BR /&gt;
You probably don't need a macro here. Use just SQL, or a merge statement in a data step if tables are/can be sorted, or a hash table if not.</description>
    <pubDate>Wed, 02 Sep 2009 21:37:22 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2009-09-02T21:37:22Z</dc:date>
    <item>
      <title>lloop through a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69105#M15001</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
First of all, i want to apologize for my poor english.&lt;BR /&gt;
&lt;BR /&gt;
I want to loop through a SAS data set and i don't know how. &lt;BR /&gt;
I pass the id to the macro updateValueById, but this not work because it pass a bundle of id, i just want to update id by id.&lt;BR /&gt;
&lt;BR /&gt;
There is my code:&lt;BR /&gt;
&lt;BR /&gt;
%MACRO UpdateData;&lt;BR /&gt;
	DATA dataset;&lt;BR /&gt;
		INFILE "c:\employes.txt"&lt;BR /&gt;
		DLM = '09'X&lt;BR /&gt;
		MISSOVER&lt;BR /&gt;
		FIRSTOBS = 2&lt;BR /&gt;
		DSD;&lt;BR /&gt;
		LENGTH	id 			8	&lt;BR /&gt;
				firstname	        $ 25	&lt;BR /&gt;
				lastname 	        $ 25	&lt;BR /&gt;
				hire_date	        8;&lt;BR /&gt;
		&lt;BR /&gt;
		INPUT 	id 				&lt;BR /&gt;
				firstname	        	&lt;BR /&gt;
				lastname 	        	&lt;BR /&gt;
				hire_date;	&lt;BR /&gt;
&lt;BR /&gt;
				%UpdateValueById(id=Id);	&lt;BR /&gt;
				&lt;BR /&gt;
	RUN;	&lt;BR /&gt;
%MEND UpdateData;&lt;BR /&gt;
&lt;BR /&gt;
%MACRO %UpdateValueById(Id);&lt;BR /&gt;
proc sql;&lt;BR /&gt;
        update dataset&lt;BR /&gt;
             set  name = 'toto'&lt;BR /&gt;
             where id = &amp;amp;Id; &lt;BR /&gt;
quit;&lt;BR /&gt;
%MEND UpdateValue;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thank you all</description>
      <pubDate>Wed, 02 Sep 2009 19:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69105#M15001</guid>
      <dc:creator>DarthSAS</dc:creator>
      <dc:date>2009-09-02T19:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: lloop through a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69106#M15002</link>
      <description>You can't call SQL statements to run inside a datastep.&lt;BR /&gt;
&lt;BR /&gt;
You probably don't need a macro here. Use just SQL, or a merge statement in a data step if tables are/can be sorted, or a hash table if not.</description>
      <pubDate>Wed, 02 Sep 2009 21:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69106#M15002</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-09-02T21:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: lloop through a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69107#M15003</link>
      <description>Hi Darth,&lt;BR /&gt;
&lt;BR /&gt;
use the call execute statement in your statement&lt;BR /&gt;
&lt;BR /&gt;
call execute('%UpdateValueById(id=' || id || ')');&lt;BR /&gt;
&lt;BR /&gt;
hope this solves your problem.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Milton</description>
      <pubDate>Thu, 03 Sep 2009 00:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69107#M15003</guid>
      <dc:creator>milts</dc:creator>
      <dc:date>2009-09-03T00:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: lloop through a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69108#M15004</link>
      <description>Thanks a lot Milton, it work fine.&lt;BR /&gt;
&lt;BR /&gt;
Best Regards

Message was edited by: Darth SAS</description>
      <pubDate>Thu, 03 Sep 2009 12:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/lloop-through-a-dataset/m-p/69108#M15004</guid>
      <dc:creator>DarthSAS</dc:creator>
      <dc:date>2009-09-03T12:48:05Z</dc:date>
    </item>
  </channel>
</rss>

