DATA Step, Macro, Functions and more

identifying a particular type of value

Reply
New Contributor
Posts: 3

identifying a particular type of value

I have various values for different variables in mutiple rows and columns showing 0/2 or 0/3 or 0/4 and so on ..

I have a total of 7 columns depicting treatmentand they have values like "0/some numeral"

I was to assign these values a "0" value. Can anyone please tell me how do i do this?

I can try to use index but for multiple row and multiple column it is not reading.

 

 

Super User
Posts: 5,438

Re: identifying a particular type of value

Test if the first position is a 0 then assign it to 0.
You can use an array to reuse that code.
Data never sleeps
New Contributor
Posts: 3

Re: identifying a particular type of value

Thankx for the responce. It is not the first position.  i have 200 rows and 7 columns and these values come randomly as 0/some numeral.. So i do not know how to assign them in such scenario.

Super User
Posts: 11,343

Re: identifying a particular type of value

Show some example data and the desired result.

New Contributor
Posts: 3

Re: identifying a particular type of value

Thankx for reaching out.

The data looks like

 

trta_1 trta_2 trta_3 ,trtb_1 trtb_2  trtb_3 wher trta and trtb are different drugs

 trta_1 and trta _2 are two different time points of the same drug.

trta_3 will be the sum of same drug at the different  time point.

 

trta_1 trta_2 trta_3    trtb_1 trtb_2  trtb_3

1/5     0/5       1/5        7/5      0/5     7/5

Super User
Posts: 5,516

Re: identifying a particular type of value

Well, you don't tell us the names of the variables, so I will call them COL1 through COL7.

 

This is the way you would correct a single variable:

 

if col1 =: '0/' then co1='0';

 

This assumes that '0/' would appear at the beginning of the variable's value.  If that's not the case, it can be done but becomes more complex.

 

To apply the same logic to all 7 variables, you would use an array:

 

array cols {7} col1-col7;

do _n_=1 to 7;

   if cols{_n_} =: '0/' then cols{_n_} = '0';

end;

 

Good luck.

Ask a Question
Discussion stats
  • 5 replies
  • 255 views
  • 0 likes
  • 4 in conversation