<?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: sas in web based storedProcess paramater handeling in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359112#M64355</link>
    <description>&lt;P&gt;You're inside a DATA step, and using symget to read the value of macro variables into DATA step variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to assign the string value % to a character variable named SM when it is null, you can do it with:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; SM=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;''&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; SM=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;'%';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full example like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let SM=;

data _null_;
  SM=symget('sm');
  if SM='' then SM='%'; 
  put SM=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But life might be easier if you change from using a datastep to macro %IF statements.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2017 17:06:15 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2017-05-16T17:06:15Z</dc:date>
    <item>
      <title>sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359109#M64354</link>
      <description>&lt;P&gt;I have a SP that gets parameters from the url like &amp;nbsp;this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro symgetvariables;&lt;BR /&gt; ccc=symget('ccc');&lt;BR /&gt; tc=symget('tc'); /*term code*/&lt;BR /&gt; tca=symget('tca'); /*term code*/&lt;BR /&gt; ay=put(symget('ay'),$4.); &lt;BR /&gt; ib=symget('ib');&lt;BR /&gt; sb=symget('ib');&lt;BR /&gt; sm=symget('sm');&lt;BR /&gt;&lt;BR /&gt; if SM= then SM=%;&lt;BR /&gt; &lt;BR /&gt;%mend;&lt;BR /&gt; &lt;BR /&gt; data _null_;&lt;BR /&gt; %symgetvariables;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what i want to happen is if a parameter is empty like&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;t&amp;amp;SMC=&amp;amp;ccc=&amp;amp;ac=&amp;amp;cs=&amp;amp;cl=&amp;amp;smd=&amp;amp;sm=&amp;amp;sl&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;like sm above have a wildcard inserted like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if SM= then SM=%;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;so that this data step where filter will work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where &amp;nbsp;("STUDENT MAJOR CODE"n LIKE "&amp;amp;SM") &amp;nbsp;however i get the error , any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="blue"&gt;NOTE: Line generated by the invoked macro "SYMGETVARIABLES".
&lt;/FONT&gt;65         ('mc');    smc=symget('smc');    smd=symget('smd');    sm=symget('sm');    sl=symget('sl');    cl=symget('cl');    ac=symget('ac');        if SM="" then SM=%;
&lt;STRONG&gt;&lt;FONT color="red"&gt;                                                                                                                                                                       _
                                                                                                                                                                       386
                                                                                                                                                                       200
ERROR 386-185: Expecting an arithmetic expression.
&lt;/FONT&gt;&lt;/STRONG&gt;
&lt;STRONG&gt;&lt;FONT color="red"&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;BR /&gt;
&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 16:50:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359109#M64354</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-05-16T16:50:37Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359112#M64355</link>
      <description>&lt;P&gt;You're inside a DATA step, and using symget to read the value of macro variables into DATA step variables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to assign the string value % to a character variable named SM when it is null, you can do it with:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="4"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; SM=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;''&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="4"&gt;then&lt;/FONT&gt;&lt;FONT face="Courier New" size="4"&gt; SM=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="4"&gt;'%';&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Full example like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let SM=;

data _null_;
  SM=symget('sm');
  if SM='' then SM='%'; 
  put SM=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But life might be easier if you change from using a datastep to macro %IF statements.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 17:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359112#M64355</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-05-16T17:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359117#M64357</link>
      <description>&lt;P&gt;ok yes Id rather use macro If statments if that allows me to do this in the %marco symgetvariables ...how would I do that&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 17:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359117#M64357</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-05-16T17:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359125#M64359</link>
      <description>&lt;P&gt;I tried this and sm still isnt set to %&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%let SM=;&lt;BR /&gt;%macro symgetvariables;&lt;BR /&gt; ccc=symget('ccc');&lt;BR /&gt; tc=symget('tc'); /*term code*/&lt;BR /&gt; tca=symget('tca'); /*term code*/&lt;BR /&gt; ay=put(symget('ay'),$4.); &lt;BR /&gt; ib=symget('ib');&lt;BR /&gt; sb=symget('ib');&lt;BR /&gt; mes=symget('mes');&lt;BR /&gt; pr=symget('pr');&lt;BR /&gt; sr=symget('sr');&lt;BR /&gt; tr=symget('tr');&lt;BR /&gt; col=symget('col');&lt;BR /&gt; mc=symget('mc');&lt;BR /&gt; smc=symget('smc');&lt;BR /&gt; smd=symget('smd');&lt;BR /&gt; sm=symget('sm');&lt;BR /&gt; sl=symget('sl');&lt;BR /&gt; cl=symget('cl');&lt;BR /&gt; ac=symget('ac');&lt;BR /&gt;%mend;&lt;BR /&gt; &lt;BR /&gt; data _null_;&lt;BR /&gt; %symgetvariables;&lt;BR /&gt; &lt;BR /&gt; if sm=" then sm='%'; &lt;BR /&gt; put sm=;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 17:44:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359125#M64359</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-05-16T17:44:34Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359147#M64360</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not sure why you would want the extra Data _null_ step to assign character variables, when your sample Where clause trying to use macro variable!?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how I would typically check Stored Process Parameters, which are by default defined as Global Macro variables&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Simulating what the Stored Process would do */
%global macVar1 macVar2;
%let macVar1=someText;  * Parameter with value;
%let macVar2=;  * Parameter without value;
/* http://.../..?.....&amp;amp;macVar1=someText&amp;amp;macVar2=&amp;amp;_debug=0 */

/* Declare a macro program the initialize empty macro parameter to % */
%macro init_macVar(p_macVar=);
	%if (%superq(&amp;amp;p_macVar) EQ ) %then 
		%let &amp;amp;p_macVar = %;
%mend;

%init_macVar(p_macVar=macVar1);
%init_macVar(p_macVar=macVar2);

%put macVar1=&amp;amp;macVar1;
%put macVar1=&amp;amp;macVar2;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 18:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359147#M64360</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2017-05-16T18:25:11Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359148#M64361</link>
      <description>&lt;P&gt;In the line:&lt;/P&gt;
&lt;PRE&gt;if sm=" then sm='%';&lt;/PRE&gt;
&lt;P&gt;It looks you you have a double quote mark.&amp;nbsp; It's intended to be two sinqle quote marks, to indicate a null value in the DATA step language.&amp;nbsp; Perhaps easier to read:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if missing(sm) then sm='%';&lt;/PRE&gt;
&lt;P&gt;That should set the data step variable SM to have the value %.&amp;nbsp; It will not set macro variable named SM.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the macro language, you could do:&lt;/P&gt;
&lt;PRE&gt;%if %sysevalf(%superq(sm)=,boolean) %then %let sm=%;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That is a way test is the macro variable named SM is blank, from &lt;A href="http://changchung.com/download/022-2009.pdf.That" target="_blank"&gt;http://changchung.com/download/022-2009.pdf.That&lt;/A&gt; would avoid the symgets, and would be outside of a DATA step (but still inside of a macro, because %IF only works inside of a macro).&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 18:25:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359148#M64361</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2017-05-16T18:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: sas in web based storedProcess paramater handeling</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359187#M64368</link>
      <description>&lt;P&gt;this seems to have fixed my problem thanks Quentin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro symgetvariables;&lt;BR /&gt; ccc=symget('ccc');&lt;BR /&gt; tc=symget('tc'); /*term code*/&lt;BR /&gt; tca=symget('tca'); /*term code*/&lt;BR /&gt; ay=put(symget('ay'),$4.); &lt;BR /&gt; ib=symget('ib');&lt;BR /&gt; sb=symget('ib');&lt;BR /&gt; mes=symget('mes');&lt;BR /&gt; pr=symget('pr');&lt;BR /&gt; sr=symget('sr');&lt;BR /&gt; tr=symget('tr');&lt;BR /&gt; col=symget('col');&lt;BR /&gt; mc=symget('mc');&lt;BR /&gt; smc=symget('smc');&lt;BR /&gt; smd=symget('smd');&lt;BR /&gt; sl=symget('sl');&lt;BR /&gt; cl=symget('cl');&lt;BR /&gt; ac=symget('ac');&lt;BR /&gt; sm=symget('sm');&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt; %if %sysevalf(%superq(ib)=,boolean) %then %let ib=%;&lt;BR /&gt; %if %sysevalf(%superq(sb)=,boolean) %then %let sb=%;&lt;BR /&gt; %if %sysevalf(%superq(sl)=,boolean) %then %let sl=%;&lt;BR /&gt; %if %sysevalf(%superq(smd)=,boolean) %then %let smd=%;&lt;BR /&gt; %if %sysevalf(%superq(sm)=,boolean) %then %let sm=%;&lt;BR /&gt; %if %sysevalf(%superq(smc)=,boolean) %then %let smc=%;&lt;BR /&gt; %if %sysevalf(%superq(ac)=,boolean) %then %let ac=%;&lt;BR /&gt; %if %sysevalf(%superq(ccc)=,boolean) %then %let ccc=%;&lt;BR /&gt; %if %sysevalf(%superq(cs)=,boolean) %then %let cs=%;&lt;BR /&gt; %if %sysevalf(%superq(cl)=,boolean) %then %let cl=%;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%mend;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2017 20:20:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sas-in-web-based-storedProcess-paramater-handeling/m-p/359187#M64368</guid>
      <dc:creator>robm</dc:creator>
      <dc:date>2017-05-16T20:20:39Z</dc:date>
    </item>
  </channel>
</rss>

