<?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: Comparison issue within a macro progrm in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24300#M4068</link>
    <description>When the %IF statement in question is executed the data step that is creating the variables used in that step has not executed.  You will need to cause that data step to execute before the %IF statement is attempted.&lt;BR /&gt;
&lt;BR /&gt;
You will also need to "re-think" the code within the %IF.</description>
    <pubDate>Wed, 19 May 2010 11:07:40 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2010-05-19T11:07:40Z</dc:date>
    <item>
      <title>Comparison issue within a macro progrm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24299#M4067</link>
      <description>Hello,&lt;BR /&gt;
the following comparison is always false within the %Tmt macro program :&lt;BR /&gt;
&lt;BR /&gt;
[pre]%If &amp;amp;stMois eq &amp;amp;MyMois and &amp;amp;stAnnee eq &amp;amp;MyAnnee and &amp;amp;stPeriode eq &amp;amp;MyPeriode and %eval(&amp;amp;lFicOk) eq 1 %Then %Do;[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Though I see 2 records in the listeFichiers table for which the clause should be true.&lt;BR /&gt;
&lt;BR /&gt;
If someone has an idea it would be great !&lt;BR /&gt;
&lt;BR /&gt;
phil&lt;BR /&gt;
&lt;BR /&gt;
[pre]%Macro CopieTable(MyTableSource, MyTableDest);&lt;BR /&gt;
	data &amp;amp;MyTableDest;&lt;BR /&gt;
		set &amp;amp;MyTableSource;&lt;BR /&gt;
	run;&lt;BR /&gt;
%Mend;&lt;BR /&gt;
&lt;BR /&gt;
%Global stFichierSource;&lt;BR /&gt;
%Global stRep;&lt;BR /&gt;
%Global stPrefD;&lt;BR /&gt;
&lt;BR /&gt;
%Global stMois;&lt;BR /&gt;
%Global stAnnee;&lt;BR /&gt;
%Global stPeriode;&lt;BR /&gt;
%Global lFicOk;&lt;BR /&gt;
&lt;BR /&gt;
%Macro Tmt(MyMois,MyAnnee,MyPeriode,MyTableDest);&lt;BR /&gt;
	&lt;BR /&gt;
	Proc Sql;&lt;BR /&gt;
		Create table listeFichiers as select distinct Fichier, Mois, Annee, Periode, FicOk, NBENREG&lt;BR /&gt;
		From AppliCft.Ficrecusdet;&lt;BR /&gt;
	Quit;&lt;BR /&gt;
&lt;BR /&gt;
	data _null_;&lt;BR /&gt;
		set listeFichiers;&lt;BR /&gt;
		PrefD="D_";&lt;BR /&gt;
		PrefC="C_";&lt;BR /&gt;
		Post="A_TRAITER\";&lt;BR /&gt;
		RepIn="C:\FichiersAImporter\";&lt;BR /&gt;
&lt;BR /&gt;
		IF Periode='A' then Rep=catx('\',RepIn,Annee,Mois,'ANNUEL',Post);&lt;BR /&gt;
		IF Periode='M' then Rep=catx('\',RepIn,Annee,Mois,'MENSUEL',Post);&lt;BR /&gt;
&lt;BR /&gt;
		Call SymputX('stMois',Mois);&lt;BR /&gt;
		Call SymputX('stAnnee',Annee);&lt;BR /&gt;
		Call SymputX('stPeriode',Periode);&lt;BR /&gt;
		Call SymputX('lFicOk',FicOk);&lt;BR /&gt;
&lt;BR /&gt;
		%put &amp;amp;stMois &amp;amp;MyMois;&lt;BR /&gt;
		%put &amp;amp;stAnnee &amp;amp;MyAnnee;&lt;BR /&gt;
		%put &amp;amp;stPeriode &amp;amp;MyPeriode;&lt;BR /&gt;
		%put &amp;amp;lFicOk;&lt;BR /&gt;
&lt;BR /&gt;
		%If &amp;amp;stMois eq &amp;amp;MyMois and &amp;amp;stAnnee eq &amp;amp;MyAnnee and &amp;amp;stPeriode eq &amp;amp;MyPeriode and &amp;amp;lFicOk eq 1 %Then %Do;&lt;BR /&gt;
&lt;BR /&gt;
			Call SymputX('stPrefD',PrefD);&lt;BR /&gt;
			&lt;BR /&gt;
			Call SymputX('stRep',Rep);&lt;BR /&gt;
			libname L "&amp;amp;stRep";&lt;BR /&gt;
&lt;BR /&gt;
			Call SymputX('stFichierSource',Fichier);&lt;BR /&gt;
&lt;BR /&gt;
			/* Si &amp;amp;MyTableDest existe déjà */&lt;BR /&gt;
			 %if %sysfunc(exist(&amp;amp;MyTableDest)) eq 1 %then %CopieTable(L.&amp;amp;stPrefD&amp;amp;stFichierSource &amp;amp;MyTableDest,&amp;amp;MyTableDest);&lt;BR /&gt;
&lt;BR /&gt;
			 /* Sinon */&lt;BR /&gt;
		    /* Si &amp;amp;MyTableDest existe déjà */&lt;BR /&gt;
			 %if %sysfunc(exist(&amp;amp;MyTableDest)) eq 0 %then %CopieTable(L.&amp;amp;stPrefD&amp;amp;stFichierSource,&amp;amp;MyTableDest);&lt;BR /&gt;
		%End;&lt;BR /&gt;
	run;&lt;BR /&gt;
%Mend;&lt;BR /&gt;
&lt;BR /&gt;
/* Début du traitement */&lt;BR /&gt;
%Tmt(12,2009,A,AppliCft.Agreg122009a);&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 19 May 2010 08:55:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24299#M4067</guid>
      <dc:creator>phil27</dc:creator>
      <dc:date>2010-05-19T08:55:25Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison issue within a macro progrm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24300#M4068</link>
      <description>When the %IF statement in question is executed the data step that is creating the variables used in that step has not executed.  You will need to cause that data step to execute before the %IF statement is attempted.&lt;BR /&gt;
&lt;BR /&gt;
You will also need to "re-think" the code within the %IF.</description>
      <pubDate>Wed, 19 May 2010 11:07:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24300#M4068</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-05-19T11:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Comparison issue within a macro progrm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24301#M4069</link>
      <description>Okay,&lt;BR /&gt;
thanks &lt;BR /&gt;
data _null_;&lt;BR /&gt;
&lt;BR /&gt;
I should not use a macro program to perform this.&lt;BR /&gt;
But I did non find a way to create the table in the [If Then] bloc inside the data step.&lt;BR /&gt;
&lt;BR /&gt;
I think that I will create a blank table and delete its records at the begining of the process so that I don't have to test if the table exists.&lt;BR /&gt;
&lt;BR /&gt;
phil</description>
      <pubDate>Wed, 19 May 2010 11:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Comparison-issue-within-a-macro-progrm/m-p/24301#M4069</guid>
      <dc:creator>phil27</dc:creator>
      <dc:date>2010-05-19T11:47:49Z</dc:date>
    </item>
  </channel>
</rss>

