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

I have a data set that looks like:

 

DirectionCUSTOMER_IDREGIONreg_Areg_BNET_SUPPLIED
1aA1.2
1aB1.3
1bA1.4
1bB1.5
2aA.46
2aB.47

 

and I want to delete the rows where the value in "region" coincides with a value of "." in that region, unfortunately I have a large number of regions and not all will show up in every query so I cant just list each region in a bunch of if statements is there any way to do a single if statement that looks like:

 

if "reg_"+value(region)=. then delete;

 

if not are there any methods other than just writing a long list of if statements?

 

Thanks! 

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hello @Daniel_MM,

 

Use the VVALUEX function:

data have;
input Direction CUSTOMER_ID $ REGION $ reg_A reg_B NET_SUPPLIED;
cards;
1 a A 1 . 2
1 a B 1 . 3
1 b A 1 . 4
1 b B 1 . 5
2 a A . 4 6
2 a B . 4 7
;

data want;
set have;
if left(vvaluex('reg_'||region))='.' then delete;
run;

View solution in original post

1 REPLY 1
FreelanceReinh
Jade | Level 19

Hello @Daniel_MM,

 

Use the VVALUEX function:

data have;
input Direction CUSTOMER_ID $ REGION $ reg_A reg_B NET_SUPPLIED;
cards;
1 a A 1 . 2
1 a B 1 . 3
1 b A 1 . 4
1 b B 1 . 5
2 a A . 4 6
2 a B . 4 7
;

data want;
set have;
if left(vvaluex('reg_'||region))='.' then delete;
run;

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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