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

Hi All,

 

I am using the IF statements to allocate numbers to variables, then I need to create a new variable that shows the total of these.

But when I use I create the new variable in another data step it doesn't add them together.

 

 

IF Active_INAa > ' ' THEN
		INAa = 1;

	IF Active_INDa  > ' '  THEN
		INDa = 2;

	IF Active_IRSa  > ' '  THEN
		IRSa = 4;

	IF Active_INIa  > ' '  THEN
		INIa = 8;

 

 

 

 

Data work.Test2;
	SET work.Test1;
	Total = INAa + INDa + IRSa + INIa;
RUN;

 

The Total column is created but is blank.

 

What am I missing here? Any help appreciated.

 

Cheers

 

Dean

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

missing+value=missing

 

so try

 

total=sum(INAa ,INDa , IRSa, INIa);  

 

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

missing+value=missing

 

so try

 

total=sum(INAa ,INDa , IRSa, INIa);  

 

DME790
Pyrite | Level 9

Thanks @novinosrin

 

Works now.

 

Cheers

 

Dean

SASKiwi
PROC Star

Try  a SUM statement if you want to add them up across your whole dataset:

 

Data work.Test2;
	SET work.Test1;
	Total + INAa + INDa + IRSa + INIa;
RUN;

 

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 923 views
  • 2 likes
  • 3 in conversation