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

Running the code below I am expecting to see a 'null' for the check2 variable from the third row.  I get a 'wrong'.  Can someone explain why?

Thank You,

data ifc;

infile cards dsd;

input one two three;

cards;

1,2,3

,2,3

1,,3

1,3, 

;

run;

data test;

set ifc;

check1 = ifc(one,.,'one is null');

check2 = ifc(two = 2,'right','wrong','null');

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

I have made some modifications on your data and your code, now you can easily figure out what is going on:

data ifc;

     infile cards dsd;

     input one two three;

     cards;

1,2,3

,0,3

1,,3

1,3, 

;

run;

data test;

     set ifc;

     check1 = ifc(one,.,'one is null');

     check2 = ifc(two,'right','wrong','null');

run;

Update: a boolean evaluation such as 'two=2' will never be missing, it is either 1 or 0, so this is why you are not getting 'null' as an outcome.

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Try :

data test2;

desc = "2 = 1"; c = 2 = 1; output;

desc = "2 = ."; c = 2 = .; output;

desc = ". = ."; c = . = .; output;

run;

pric print data=test2; run;

PG

PG
Haikuo
Onyx | Level 15

I have made some modifications on your data and your code, now you can easily figure out what is going on:

data ifc;

     infile cards dsd;

     input one two three;

     cards;

1,2,3

,0,3

1,,3

1,3, 

;

run;

data test;

     set ifc;

     check1 = ifc(one,.,'one is null');

     check2 = ifc(two,'right','wrong','null');

run;

Update: a boolean evaluation such as 'two=2' will never be missing, it is either 1 or 0, so this is why you are not getting 'null' as an outcome.

Steelers_In_DC
Barite | Level 11

Excellent, thank you!

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 563 views
  • 0 likes
  • 3 in conversation