BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
spirto
Obsidian | Level 7

Hello all,

 

is it possible to use mathematical operations in the values() statement? For example

 

data have;
input x $ y z;
datalines;
a 1 2
b 3 4
;

proc sql;

insert into have values('c',5,6);
insert into have values('d',3*1,7-6);
quit;

 

The first insert statement works but the second does not. Is it possible to use mathematical operations?

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

data have;

input x $ y z;

datalines;

a 1 2

b 3 4

;

proc sql;

insert into have values('c',5,6);

insert into have values('d',%EVAL(3*1),%EVAL(7-6));

quit;

Thanks,
Suryakiran

View solution in original post

5 REPLIES 5
SuryaKiran
Meteorite | Level 14

data have;

input x $ y z;

datalines;

a 1 2

b 3 4

;

proc sql;

insert into have values('c',5,6);

insert into have values('d',%EVAL(3*1),%EVAL(7-6));

quit;

Thanks,
Suryakiran
spirto
Obsidian | Level 7

Thank you for your response! A followup question: how would I use the %EVAL function with date literals.

 

For example how can I do

 

insert into have values('d',%EVAL(3*1),%EVAL('29DEC2015'd-'28DEC2015'd));

ballardw
Super User

No reason to use %eval just use ('29DEC2015'd-'28DEC2015'd)

 

Though learning th INTCK function will help in the future.

spirto
Obsidian | Level 7

When I tried using just the literals I got an error but using %sysevalf worked. I guess date literals are considered floating point values and not purely interger values

 

insert into have values('d',%eval(3*1),%sysevalf('29DEC2015'd-'28DEC2015'd));

SuryaKiran
Meteorite | Level 14

proc sql;

insert into have values('c',5,6);

insert into have values('d',%EVAL(3*1),%SYSFUNC(INTCK(DAYS,'28DEC2015'd,'29DEC2015'd)));

quit;

Thanks,
Suryakiran

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
  • 5 replies
  • 1692 views
  • 0 likes
  • 3 in conversation