<?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 How to use Colon (:) to resolve a condition in Macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841562#M332753</link>
    <description>&lt;P&gt;I am trying to resolve the condition of the macro in my code.&amp;nbsp; I have the two conditions&amp;nbsp; where I want to&amp;nbsp; output the error in log based on the input macro variable 'fld' . If it starts with numeric then it have to put one condition otherwise it need to put another error in log ( most of my names with 'SC' if its not numeric&lt;/P&gt;
&lt;P&gt;In my example fld= 101-281 then I am expecting&amp;nbsp; to print 'ERROR: 101281 starts with Numeric", My second one is mostly my name starts with 'SC' how can I control the second condition using the ':' colon in the % if condition to print 'ERROR:&amp;amp;dsn ( numeric values of the 'fld' name)&amp;nbsp; starts with alpha character SC"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to use ':' in dataset condition but not sure how to use it the macro, instead of writing every&amp;nbsp; name in the 'If' Condtion.&lt;/P&gt;
&lt;P&gt;Thank you for your inputs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check (fld=);
*%global output dsn;
%let output = %sysfunc(compress(&amp;amp;fld, "-"));


%if &amp;amp;output ^=: SC %then %do;
	%let dsn= %substr(&amp;amp;output.,1,6);

data _281;
	putlog  "ERROR: &amp;amp;dsn starts with Numeric";
run;

%end;

%else %if &amp;amp;output = :SC %then %do;
	%let dsn= %substr(&amp;amp;output.,3,6);
data _109;
	putlog  "ERROR:&amp;amp;dsn starts with alpha character SC";
run;
%end;

%put &amp;amp;output &amp;amp;dsn;


%mend;

%check (fld= 101-281);
%check (fld= 121-281);
%check (fld= SC100426);
%check (fld= SC100843);
%check (fld= SC102126);
%check (fld= SC105143);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Oct 2022 01:49:32 GMT</pubDate>
    <dc:creator>SASuserlot</dc:creator>
    <dc:date>2022-10-31T01:49:32Z</dc:date>
    <item>
      <title>How to use Colon (:) to resolve a condition in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841562#M332753</link>
      <description>&lt;P&gt;I am trying to resolve the condition of the macro in my code.&amp;nbsp; I have the two conditions&amp;nbsp; where I want to&amp;nbsp; output the error in log based on the input macro variable 'fld' . If it starts with numeric then it have to put one condition otherwise it need to put another error in log ( most of my names with 'SC' if its not numeric&lt;/P&gt;
&lt;P&gt;In my example fld= 101-281 then I am expecting&amp;nbsp; to print 'ERROR: 101281 starts with Numeric", My second one is mostly my name starts with 'SC' how can I control the second condition using the ':' colon in the % if condition to print 'ERROR:&amp;amp;dsn ( numeric values of the 'fld' name)&amp;nbsp; starts with alpha character SC"&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am able to use ':' in dataset condition but not sure how to use it the macro, instead of writing every&amp;nbsp; name in the 'If' Condtion.&lt;/P&gt;
&lt;P&gt;Thank you for your inputs.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check (fld=);
*%global output dsn;
%let output = %sysfunc(compress(&amp;amp;fld, "-"));


%if &amp;amp;output ^=: SC %then %do;
	%let dsn= %substr(&amp;amp;output.,1,6);

data _281;
	putlog  "ERROR: &amp;amp;dsn starts with Numeric";
run;

%end;

%else %if &amp;amp;output = :SC %then %do;
	%let dsn= %substr(&amp;amp;output.,3,6);
data _109;
	putlog  "ERROR:&amp;amp;dsn starts with alpha character SC";
run;
%end;

%put &amp;amp;output &amp;amp;dsn;


%mend;

%check (fld= 101-281);
%check (fld= 121-281);
%check (fld= SC100426);
%check (fld= SC100843);
%check (fld= SC102126);
%check (fld= SC105143);

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 01:49:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841562#M332753</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2022-10-31T01:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Colon (:) to resolve a condition in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841563#M332754</link>
      <description>&lt;P&gt;You can't use '=:' in macro logic. It is simply not available. You can do the same thing though like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %substr(&amp;amp;output,1,2) ^= SC %then %do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Oct 2022 02:14:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841563#M332754</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-10-31T02:14:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use Colon (:) to resolve a condition in Macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841581#M332763</link>
      <description>&lt;P&gt;Unfortunately, the colon operator i&lt;SPAN&gt;s not in the list of macro operators. Would be cool though.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Oct 2022 07:51:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-Colon-to-resolve-a-condition-in-Macro/m-p/841581#M332763</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-10-31T07:51:01Z</dc:date>
    </item>
  </channel>
</rss>

