BookmarkSubscribeRSS Feed
pinkyc
Calcite | Level 5


I have a dataset as such:

pat_ID     Code_1     Code_2     Code_3     Code_4     Code_5

A               111

B               121          111          155

C               155          123          111          111

D               123

E                111          123              155          666

F                332          111         

...

I have a proc format specifying the range of values that I want to match Code_1 = 1, or else = 0 and then I would sort the observations with Code_1 matching my proc format in one table and the ones that don't match in another (in my example using match as the variable).  Is there a method to write an array or loop to check for each range of codes I want against Code_2, Code_3?  The condition would be say If CODE_1 = '111' OR Code_2 = '111' not AND.

proc format;

value $ match

'111-123' = 1

155 = 1;

.....

other = 0'

run;

data pat_codes2;

set pat_codes1;

match=put(Code_1, $match.);

run;

1 REPLY 1
ballardw
Super User

First you may need to check whether the format does what you expect as shown in your post. Did you mean to have a range of values '111'  -  '123' or only looking for the long string 111-123?

I suspect the first. If so value of '12' and  '1200' will be formatted as 1.

Also you have something missing such as a ; to end the format (possibly a typo with the single quote) and the existing ; before the other should not be there. Also there should not be a space between the $ the name of the format.

I think you might want display what you expect the output to look like.

Also

If CODE_1 = '111' OR Code_2 = '111'

is perfectly acceptable SAS code.

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1 reply
  • 874 views
  • 3 likes
  • 2 in conversation