Help using Base SAS procedures

where in condition of proc export

Accepted Solution Solved
Reply
Contributor
Posts: 68
Accepted Solution

where in condition of proc export

[ Edited ]

Hello , good morning,

I want place a condition "where " in a proc export like this :

proc export data=work.refec9 (where=(acteur="toto") (statut<>"tata")) outfile="\\serveur\\dossier\sousdossier\truc.xlsx" dbms=XLSX replace ;
sheet="a_traiter";
run;

I have tried to follow the law which are here with unsuccess : http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001000998.htm

 

Can you give me your opinion

 

Thanks for the help

 

[KB] fixed the link


Accepted Solutions
Solution
‎12-01-2017 08:37 AM
Super User
Posts: 10,278

Re: where in condition of proc export

Posted in reply to azertyuiop

A where condition needs to be a syntactically valid boolean expression.

(acteur="toto") (statut<>"tata")

clearly is not.

(acteur="toto" and statut<>"tata")

or

(acteur="toto" or statut<>"tata")

are.

 

You just have to keep reading on in the documentation:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131192.htm

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Solution
‎12-01-2017 08:37 AM
Super User
Posts: 10,278

Re: where in condition of proc export

Posted in reply to azertyuiop

A where condition needs to be a syntactically valid boolean expression.

(acteur="toto") (statut<>"tata")

clearly is not.

(acteur="toto" and statut<>"tata")

or

(acteur="toto" or statut<>"tata")

are.

 

You just have to keep reading on in the documentation:

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000131192.htm

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Contributor
Posts: 68

Re: where in condition of proc export

Posted in reply to KurtBremser

Excellent for your link , I keep this in my paper note .

Super User
Super User
Posts: 9,599

Re: where in condition of proc export

Posted in reply to azertyuiop

This:

(where=(acteur="toto") (statut<>"tata"))

 

Is not a valid where clause.  Where clause take the form:

where <condition> [logical operator <condition>];

 

So:

(where=(acteur="toto" and statut<>"tata"))

Would work.

You are trying to do a where clause like its options - e.g. keep or drop or where.

Contributor
Posts: 68

Re: where in condition of proc export

I have tried this code :

 

proc export data=work.ma_table (where=(champ1<>"XXXX" and champ2="YYYY" )) outfile="\\serveur\\dossier\sous dossier\\fichier.xlsx" dbms=XLSX replace ; sheet="nomfeuille2"; run;

It's ok in my side , there is a result in out Smiley Very Happy

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 517 views
  • 2 likes
  • 3 in conversation