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

Hi all,

I have 3 data vectors read in iml which are

截屏2020-06-18下午7.24.44.png

 I want to mark these data by following discipline:

  • label = put where k<k0;
  • label = call where k>k0;
  • label = mix where k=k0.

   How can I do? Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
IanWakeling
Barite | Level 11

You can use essentially the same syntax to construct Q like this:

  lab = choose(k<k0,'put','mix');
  lab = choose(k>k0,'call',lab);
  Q = choose(k<k0, p, (p+c)/2);
  Q = choose(k>k0, c, Q);
  print k0 k lab p c Q;

View solution in original post

3 REPLIES 3
IanWakeling
Barite | Level 11

I think this will work

  lab = choose(k<k0,'put','mix');
  lab = choose(k>k0,'call',lab);
  print k0 k lab;

however you may need to screen missing values out first if you have them.

Sasulee
Fluorite | Level 6
Awesome, it works, thanks!
however, how can I use this info to define another row? like
create a new vector Q
Q=p (a numeric variable ) if lab='put';
Q=c (a numeric variable ) if lab='call';
Q=(p+c)/2 if lab='mix';
The vector should be continuous, like
p c lab Q
1 2 put 1
2 3 call 3
4 5 call 5
6 7 mix 6.5

Can you help?
IanWakeling
Barite | Level 11

You can use essentially the same syntax to construct Q like this:

  lab = choose(k<k0,'put','mix');
  lab = choose(k>k0,'call',lab);
  Q = choose(k<k0, p, (p+c)/2);
  Q = choose(k>k0, c, Q);
  print k0 k lab p c Q;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Multiple Linear Regression in SAS

Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.

Find more tutorials on the SAS Users YouTube channel.

From The DO Loop
Want more? Visit our blog for more articles like these.
Discussion stats
  • 3 replies
  • 935 views
  • 5 likes
  • 2 in conversation