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

Obs

ID

time

timesecond

1

MC_001

0

4.67

2

MC_001

6

4.00

3

MC_002

12

4.17

4

MC_002

18

4.67

5

MC_003

24

5.50

6

MC_003

30

4.67

7

MC_004

36

3.40

8

MC_004

42

3.67

 

The data set above and code below.

 

data longICP1;

set longICP;

if SID="MR_001" and 0<time<=900 and timesecond=4.67 then t=1; else t=0;

if SID="MR_002" and 0<time<=900 and timesecond=467. then t=1; else t=0;

if SID="MR_003" and 0<time<=900 and timesecond=5.50 then t=1; else t=0;

if SID="MR_004" and 0<time<=900 and timesecond=8.00 then t=1; else t=0;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

The way you have setup the logic the value of T only depends on the last set of IF/THEN/ELSE statements.

 

Perhaps you meant something more like this?

t=0;
if SID="MR_001" and 0<time<=900 and timesecond=4.67 then t=1; 
else if SID="MR_002" and 0<time<=900 and timesecond=467. then t=1; 
else if SID="MR_003" and 0<time<=900 and timesecond=5.50 then t=1; 
else if SID="MR_004" and 0<time<=900 and timesecond=8.00 then t=1; 

 

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

The way you have setup the logic the value of T only depends on the last set of IF/THEN/ELSE statements.

 

Perhaps you meant something more like this?

t=0;
if SID="MR_001" and 0<time<=900 and timesecond=4.67 then t=1; 
else if SID="MR_002" and 0<time<=900 and timesecond=467. then t=1; 
else if SID="MR_003" and 0<time<=900 and timesecond=5.50 then t=1; 
else if SID="MR_004" and 0<time<=900 and timesecond=8.00 then t=1; 

 

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
  • 1 reply
  • 391 views
  • 1 like
  • 2 in conversation