<?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 use observations of one dataset as macro variables in another program? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374787#M89776</link>
    <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input VAR $;
cards;
Name
age
sex
address
language
run;
proc sql noprint;
  select VAR into :varlist separated by ' ' from HAVE;
quit;

%macro test(start=, stop=);
  %put Replace with actual code &amp;amp;=start &amp;amp;=stop;
%mend;

%macro loop;
   %local i;
    %do i=1 %to &amp;amp;sqlobs.-1;
      %test(START=%scan(&amp;amp;varlist, &amp;amp;i),STOP=%scan(&amp;amp;varlist, &amp;amp;i+1));
  %end;
%mend;
%loop;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace with actual code START=Name STOP=age&lt;BR /&gt;Replace with actual code START=age STOP=sex&lt;BR /&gt;Replace with actual code START=sex STOP=address&lt;BR /&gt;Replace with actual code START=address STOP=language&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jul 2017 05:29:29 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2017-07-11T05:29:29Z</dc:date>
    <item>
      <title>How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374777#M89774</link>
      <description>&lt;P&gt;Hi Mate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need help from you guys. Let me explain you my problem firtst. I have created a single variable dataset (All the observation of this dataset are variables for my other programming.). Now i need to use the observations in a sequence like 1st observation and 2nd observation will be considered as Macro variables&amp;nbsp;"START" and&amp;nbsp;"STOP" in another programe and once the macro finishes forst ittration then 2nd observation should be "START" and 3rd observation should be "STOP" variable. Like this, the entire observations need to be used as derived Macro variables in another programme.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Dataset_1&lt;/P&gt;&lt;P&gt;obs Title&lt;/P&gt;&lt;P&gt;01 Name&lt;/P&gt;&lt;P&gt;02 age&lt;/P&gt;&lt;P&gt;03 sex&lt;/P&gt;&lt;P&gt;04 address&lt;/P&gt;&lt;P&gt;05 language&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Programme:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro test (Start= , Stop= );&lt;/P&gt;&lt;P&gt;if var1= &amp;amp;START then Seq+1;&lt;/P&gt;&lt;P&gt;if var1= &amp;amp;STOP then seq+1;&lt;/P&gt;&lt;P&gt;if seq=1 or var1= &amp;amp;STOP;&lt;/P&gt;&lt;P&gt;%mend test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please provide me a solution to use the observation of dataset_1 as macro variables in the above programe in the above specified sequence.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 04:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374777#M89774</guid>
      <dc:creator>satish78652</dc:creator>
      <dc:date>2017-07-11T04:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374784#M89775</link>
      <description>&lt;P&gt;Look at CALL EXECUTE if I understand your question correctly. It's ambiguous.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The example in the documentation shows how a dataset can drive a macro.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 05:22:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374784#M89775</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-11T05:22:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374787#M89776</link>
      <description>&lt;P&gt;Like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data HAVE;
input VAR $;
cards;
Name
age
sex
address
language
run;
proc sql noprint;
  select VAR into :varlist separated by ' ' from HAVE;
quit;

%macro test(start=, stop=);
  %put Replace with actual code &amp;amp;=start &amp;amp;=stop;
%mend;

%macro loop;
   %local i;
    %do i=1 %to &amp;amp;sqlobs.-1;
      %test(START=%scan(&amp;amp;varlist, &amp;amp;i),STOP=%scan(&amp;amp;varlist, &amp;amp;i+1));
  %end;
%mend;
%loop;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Replace with actual code START=Name STOP=age&lt;BR /&gt;Replace with actual code START=age STOP=sex&lt;BR /&gt;Replace with actual code START=sex STOP=address&lt;BR /&gt;Replace with actual code START=address STOP=language&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 05:29:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374787#M89776</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-11T05:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374789#M89777</link>
      <description>&lt;P&gt;Or like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data _null_;
  set HAVE;
  PREV=lag(VAR);
  if PREV ne ' ' then 
  call execute('%test(start='||PREV||',stop='||VAR||');');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 05:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374789#M89777</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-11T05:35:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374802#M89783</link>
      <description>&lt;P&gt;The programme provided is working only for numeric variables. Can you please modify it to work for character variable as well?&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 06:24:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374802#M89783</guid>
      <dc:creator>satish78652</dc:creator>
      <dc:date>2017-07-11T06:24:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374805#M89784</link>
      <description>How is "Name" a numeric?</description>
      <pubDate>Tue, 11 Jul 2017 06:35:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374805#M89784</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-11T06:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374806#M89785</link>
      <description>&lt;P&gt;the programe is not working for the variables like name, address and language.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 06:37:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374806#M89785</guid>
      <dc:creator>satish78652</dc:creator>
      <dc:date>2017-07-11T06:37:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374807#M89786</link>
      <description>It is and I even provided the outputs</description>
      <pubDate>Tue, 11 Jul 2017 06:39:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374807#M89786</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-11T06:39:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to use observations of one dataset as macro variables in another program?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374818#M89792</link>
      <description>&lt;P&gt;Thank you for your help Chriz. Now i got it.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2017 07:25:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-observations-of-one-dataset-as-macro-variables-in/m-p/374818#M89792</guid>
      <dc:creator>satish78652</dc:creator>
      <dc:date>2017-07-11T07:25:21Z</dc:date>
    </item>
  </channel>
</rss>

