BookmarkSubscribeRSS Feed
mariopellegrini
Pyrite | Level 9

 

I found a program sas the symbol ^, I do not understand what it means, someone can explain to me?

 

data _null_;

x= ^-2; put x=;
x= ^-1; put x=;
x= ^0; put x=;
x= ^1; put x=;
x= ^2; put x=;
x= ^3; put x=;
x= 1*^-2; put x=;
x= 2*^-1; put x=;
x= 3*^0; put x=;

run;

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

It means NOT: https://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm

 

However in the context of what your showing below, well, I really don't know where you got the code from, but it isn't very helpful.  What are you trying to do?  From a readablity sense I would use textual varieties, e.g. ne for not equal, rather than ^=.  Also ^ could be escape char, so would avoid it.

rivieralad
Obsidian | Level 7

Beaten to it by RW9!

 

Yes, ^ is shorthand for not and I remember using it on IBM mainframes many, many years ago (so far back it was either SAS 5.18 or 6.02).

 

I wouldn't try and guess why the code was written like it was but there are far more easily understood ways of getting the same results.

 

It is probably a leftover fromsomeone experimenting before using something similar in a "real" SAS program.

 

Regards


Chris

Astounding
PROC Star

While it is true that the symbol gets interpreted as "not", there is more that you need to know to figure out what this code is doing.  Putting "not" in front of a number turns it from a numerical value into a logical expression.  SAS evaluates any logical expression as either true or false, and returns a "1" for true expressions and a "0" for false expressions.  "not" means do the opposite:  return "0" for true expressions, and "1" for false expressions.  What does SAS consider to be true or false?  Well, the rule is that zero and missing values are false, and anything else (including negative numbers) is considered to be true.  So in every case, "not" plus a number gets replaced by either "1" or "0", and then the math gets carried out.  I agree that this code must be an experiment, just to get more insight into how SAS works with logical expressions.

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
  • 3 replies
  • 870 views
  • 1 like
  • 4 in conversation