I have a data set that looks like:
| Direction | CUSTOMER_ID | REGION | reg_A | reg_B | NET_SUPPLIED |
| 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 |
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!
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;
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.