<?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: using proc sql outobs=1  and selecting into a variable how do i do that? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351929#M81990</link>
    <description>&lt;P&gt;You need to create a macro variable not a outobs=1 or create a dataset. Your current code will only output the data to the result window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1y2jszlvs4hugn14nooftfrxhp3.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1y2jszlvs4hugn14nooftfrxhp3.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select max(age) into :max_age
from sashelp.class;
quit;

%put &amp;amp;max_age;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Apr 2017 21:45:00 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-04-20T21:45:00Z</dc:date>
    <item>
      <title>using proc sql outobs=1  and selecting into a variable how do i do that?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351928#M81989</link>
      <description>&lt;P&gt;if I have 1 observation from a proc sql query how do i assign that to a variable? that i want to load into a variable&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql outobs=1;&lt;BR /&gt;SELECT "Qa Test Id"n FROM ROBM.QUAL102;&lt;BR /&gt;run&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so that further on I can do the below sort if the &amp;amp;var (QA Test ID) &amp;nbsp;from the select above is 35 for instance&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if &amp;amp;var = 35 then do;
 proc sort data=ROBM.QUAL102;
  by TERM_CODE "Id"n CRN;
quit;
end;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 21:39:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351928#M81989</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-04-20T21:39:47Z</dc:date>
    </item>
    <item>
      <title>Re: using proc sql outobs=1  and selecting into a variable how do i do that?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351929#M81990</link>
      <description>&lt;P&gt;You need to create a macro variable not a outobs=1 or create a dataset. Your current code will only output the data to the result window.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1y2jszlvs4hugn14nooftfrxhp3.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n1y2jszlvs4hugn14nooftfrxhp3.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select max(age) into :max_age
from sashelp.class;
quit;

%put &amp;amp;max_age;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Apr 2017 21:45:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351929#M81990</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-04-20T21:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: using proc sql outobs=1  and selecting into a variable how do i do that?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351931#M81991</link>
      <description>&lt;P&gt;I think you are looking to create a macro variable. &amp;nbsp;If so there is no need for the OUTOBS setting since unless you tell it to generate multiple variables or make a delimited list it will only write out one value into the macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  SELECT "Qa Test Id"n 
    into :mvar
    FROM ROBM.QUAL102
  ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then test the macro variable, but to conditionally generate code you will need to wrap the code into a macro o ruse some other method to generate the code. IF/THEN statements only work in DATA STEPS or some procs that support data step like data processing code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro xxx ;
%if (&amp;amp;mvar = 35) %then %do;
proc sort data=ROBM.QUAL102;
  by TERM_CODE "Id"n CRN;
run;
%end;
%mend xxx;
%xxx;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2017 21:48:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/351931#M81991</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-04-20T21:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: using proc sql outobs=1  and selecting into a variable how do i do that?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/352059#M82026</link>
      <description>&lt;P&gt;that works great thanks&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 05:29:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/using-proc-sql-outobs-1-and-selecting-into-a-variable-how-do-i/m-p/352059#M82026</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-04-21T05:29:43Z</dc:date>
    </item>
  </channel>
</rss>

