BookmarkSubscribeRSS Feed
hporter
Obsidian | Level 7

I have a dataset A that looks like:

Account# Userno
123 1
456 2

 

I have a dataset B that looks like:

Userno
1
2

 

There are thousands of accounts and around 15 users total. Right now I have a datastep where I assign accounts to users in a loop like so:

data example;
set work.A;
p = 1 + mod(_n_-1,nobs);
set work.B point=p nobs=nobs;
run;

 

What I need is something that does not function with the 'point' function in SAS I think...

 

I want to add a conditional that would be like this:
data example;
set work.A;
p = 1 + mod(_n_-1,nobs);
set work.B where ((userno in (1,2,3) and flag = 1) OR (userno in (4,5,6) and flag in (1,0)));
point=p nobs=nobs;
run;

 

As far as I know, you can't add a 'WHERE' when you use the POINT function in the SET option. Does anyone have a recommendation on how to accomplish this another way, or if I'm not being explicit enough, please let me know.

 

Thanks,

1 REPLY 1
PaigeMiller
Diamond | Level 26

What is variable FLAG? It's not in your data sets.

 

It's really hard to generalize from data that has just two observations, but it seems like you just want to do a MERGE with some conditions on variable FLAG (which we know nothing about).

 

You state you need a loop and POINT=, but I don't see those requirements as necessary or helpful at this time. Instead of requiring certain code to be used (its rarely a good idea to specify that certain code should be used), please explain the problem in more detail, and provide a larger example, I think that will be more helpful.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 613 views
  • 0 likes
  • 2 in conversation