Using conditions in excel file

Reply
Occasional Contributor
Posts: 12

Using conditions in excel file

 

Hello,

 

I have a group of conditions in a excel sheet like this:

CellA1: condition
Cell A2: if name <> '' AND date < &date_ref then result=1;
Cell A3: else if name <> '' AND date > &date_ref then result=-1;
Cell A4: else result=0;

 

where &date_ref is a the reference to a SAS macro variable (like '01Nov2015:00:00:00'dt).

 

I have imported this sheet to a SAS dataset (cond_set), and now I would like to apply this conditions in a different dataset. Something like this:

 

data new_set;
set test;
<check those conditions here>;
run;

Is this possible?

 

Best regards,

 

Brunosm

Grand Advisor
Posts: 17,396

Re: Using conditions in excel file

[ Edited ]

Sure, you can either create a text file that contains the SAS code and run it, or create a few macro variables that are then resolved.

Here's an example of the first method. The second is relatively straightforward.

 

http://www2.sas.com/proceedings/sugi29/175-29.pdf

 

Occasional Contributor
Posts: 12

Re: Using conditions in excel file

Hello Reeza,

 

thanks for the reply but... I can't see the examples...

Grand Advisor
Posts: 17,396

Re: Using conditions in excel file

I updated the link above.
Occasional Contributor
Posts: 12

Re: Using conditions in excel file

Thanks!

Esteemed Advisor
Esteemed Advisor
Posts: 7,233

Re: Using conditions in excel file

Whilst it may be technically possible to do this, I would advise you don't.  Excel is not a SAS code editor.  What is the purpose behind this?  What conditions do you need to check?  Is this to capture some user input or something?  I can only say that trying to do things this way is going to cause you all kinds of problems - just to start with what kind of logic/syntax checking are you going to do on that spreadsheet?  I can guarentee you every user will put something into the sheet that you don't expect and haven't handled for and it will go wrong.

Occasional Contributor
Posts: 12

Re: Using conditions in excel file

Hello RW9,

 

thanks for the reply. I think you are... right!

 

I'm going to try a different approach and i'll give feedback on this.

 

Thanks a lot

 

Brunosm

Ask a Question
Discussion stats
  • 6 replies
  • 376 views
  • 3 likes
  • 3 in conversation