BookmarkSubscribeRSS Feed
brunosm
Obsidian | Level 7

 

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

6 REPLIES 6
Reeza
Super User

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

 

brunosm
Obsidian | Level 7

Hello Reeza,

 

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

Reeza
Super User
I updated the link above.
brunosm
Obsidian | Level 7

Thanks!

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

brunosm
Obsidian | Level 7

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 852 views
  • 3 likes
  • 3 in conversation