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

Hello,

I want to program linear thresholds for continuous variables. In my case, it means that if the values of variable A are <=30, then these values shall be put (placed) as 30. Otherwise the variable A shall be applied.

Therefore my code is:

A=A_t30;
if A_t30<=30 then A_t30=30;

Then all values of variable A_t30 are placed as 30. Mean is 30; SD is 0; Minimum is 30; Maximum is 30.

 

Do you know my mistake?

I am glad if you can help me. Thank you very much.

Kind regards

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Show some example data, some with problem values and some without. And the entire code used.

 

If A_t30 does not exist prior to executing this statement:

A = A_t30;

Then you created a variable A_t30 and all values were missing. So since missing is treated as < 30 it gets set to 30.

 

Perhaps you intended to use

A_t30 = A;

assigning the value of the variable A to A_t30 before the test.

The receiving side of value assignment is always the left of the = sign.

View solution in original post

2 REPLIES 2
ballardw
Super User

Show some example data, some with problem values and some without. And the entire code used.

 

If A_t30 does not exist prior to executing this statement:

A = A_t30;

Then you created a variable A_t30 and all values were missing. So since missing is treated as < 30 it gets set to 30.

 

Perhaps you intended to use

A_t30 = A;

assigning the value of the variable A to A_t30 before the test.

The receiving side of value assignment is always the left of the = sign.

Epidemiologist
Calcite | Level 5

Thank you very much. It was very helpful. 🙂

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
  • 2 replies
  • 410 views
  • 0 likes
  • 2 in conversation