<?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: proc sql into clause in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367434#M275372</link>
    <description>&lt;P&gt;After the first QUIT statement, add this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let n = &amp;amp;n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will remove the leading blanks from the value of &amp;amp;n that are causing the problem.&amp;nbsp; There are other ways to solve the leading blanks, that's just one easy way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jun 2017 16:46:04 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-06-15T16:46:04Z</dc:date>
    <item>
      <title>proc sql into clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367433#M275371</link>
      <description>&lt;P&gt;Hello all;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have a dataset like this&lt;/P&gt;&lt;P&gt;Country Sales&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;/P&gt;&lt;P&gt;B &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;200&lt;/P&gt;&lt;P&gt;A &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;500&lt;/P&gt;&lt;P&gt;C &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;600&lt;/P&gt;&lt;P&gt;D &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;800&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to create datasets for individual countries, Like in above example there are 4 distnict countries so i want to create 4 datasets using proc sql into clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote a patial code which is given below-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data info;&lt;BR /&gt;input country $ sales;&lt;BR /&gt;cards;&lt;BR /&gt;a 100&lt;BR /&gt;b 100&lt;BR /&gt;a 200&lt;BR /&gt;c 500&lt;BR /&gt;d 300&lt;BR /&gt;;&lt;BR /&gt;run; proc print; run;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select count(distinct(country)) into :n separated by ''&lt;BR /&gt;from work.info;&lt;BR /&gt;quit;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;proc sql;&lt;BR /&gt;select distinct(country) into :var1-:var&amp;amp;n.&lt;BR /&gt;from work.info;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;%macro name();&lt;BR /&gt;%do i=1 %to &amp;amp;n.;&lt;BR /&gt;data &amp;amp;&amp;amp;country&amp;amp;i..new;&lt;BR /&gt;set work.new;&lt;BR /&gt;where country= &amp;amp;&amp;amp;country&amp;amp;i;&lt;BR /&gt;run;&lt;BR /&gt;%end;&lt;BR /&gt;%mend name;&lt;BR /&gt;% name();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but in log window error is showing as "Statement is not valid or it is used out of proper order."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i am not able to create datasets like country1 country2..and so on..&lt;BR /&gt;and i have one more doubt, where these datasets will be available, will I have to use libname to save these datasets in a particular location, if yes then how it will use.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 16:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367433#M275371</guid>
      <dc:creator>Ankur32</dc:creator>
      <dc:date>2017-06-15T16:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql into clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367434#M275372</link>
      <description>&lt;P&gt;After the first QUIT statement, add this line:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let n = &amp;amp;n;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will remove the leading blanks from the value of &amp;amp;n that are causing the problem.&amp;nbsp; There are other ways to solve the leading blanks, that's just one easy way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 16:46:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367434#M275372</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-06-15T16:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql into clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367437#M275373</link>
      <description>&lt;P&gt;that problem has been solved by using separated by ' '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but problem is somewhere in parametrize macro and&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jun 2017 16:49:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367437#M275373</guid>
      <dc:creator>Ankur32</dc:creator>
      <dc:date>2017-06-15T16:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql into clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367444#M275374</link>
      <description>If you know where the problem is, please say that upfront. &lt;BR /&gt;Check your WHERE clause, it likely needs quotes. &lt;BR /&gt;&lt;BR /&gt;As always, note that splitting your datasets is usually not good practice but I assume this is homework/practice not a real implementation.</description>
      <pubDate>Thu, 15 Jun 2017 17:12:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367444#M275374</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-06-15T17:12:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql into clause</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367825#M275375</link>
      <description>&lt;P&gt;Why are you trying to use macro variables named COUNTRY when you created VAR1 - varn.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also I think you were going to be comparing 'A' to 'a', at least from your example data.&lt;/P&gt;
&lt;PRE&gt;%macro name();
%do i=1 %to &amp;amp;n.;
data &amp;amp;&amp;amp;country&amp;amp;i..new;
set work.new;
where UPcase(country)= upcase( "&amp;amp;&amp;amp;Var&amp;amp;i");
run;
%end;
%mend name;&lt;/PRE&gt;
&lt;P&gt;Also you only need one proc sql.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
select distinct(country) into :var1-:var9999 
from work.info;
quit;
%let n = &amp;amp;sqlobs;&lt;/PRE&gt;
&lt;P&gt;Provide a larger number than you expect and only the ones assigned values are created. The automatic variable &amp;amp;sqlobs holds the number of the results from the select.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use&lt;/P&gt;
&lt;P&gt;%put _user_; to verify that only the number of VAR variables is created that you need.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jun 2017 17:38:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sql-into-clause/m-p/367825#M275375</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-16T17:38:21Z</dc:date>
    </item>
  </channel>
</rss>

