Help using Base SAS procedures

if-then follow up to renaming

Reply
Regular Contributor
Posts: 161

if-then follow up to renaming

I have a follow up question. I want to change these values but when I do it my values are only 0's and 1's.

data IEEE.item_coded (drop=item1-item116 iii);

set IEEE.item;

array f_item(116);

array item(*) item1-item116;

do iii=1 to 116;

  if item{iii}<0.000623175 then f_item{iii}=3;

   else if item{iii} lt 0.002864969 then f_item{iii}=2;

   else if item{iii} lt 0.013617708 then f_item{iii}=1;

   else if item{iii} le 0.431834293 then f_item{iii}=0;

  if item{iii} lt 0.001041523 then f_item{iii}=2;

   else if item{iii} lt 0.008116862 then f_item{iii}=1;

   else if item{iii} le 0.431834293 then f_item{iii}=0;

  if item{iii} lt 0.002864969 then f_item{iii}=1;

   else if item{iii} le 0.431834293 then f_item{iii}=0;

end;

run;

Super User
Super User
Posts: 6,499

Re: if-then follow up to renaming

You appear to be missing some ELSE keywords.

The first block of IF/THEN/ELSE clauses will convert the value to 0,1,2, or 3.

The second block will then flip those into 2 or 0.  The 0's will be come 1's and the higher numbers will be 0's.

The third block will then flip the 1/0 values.

Perhaps you are trying to create three new variables from each existing variable?

Or perhaps you really wanted to do some type of aggregation over the values? If so did you want to aggregate horizontally across the variables in a particular observation or vertically across the observations in your dataset?

Ask a Question
Discussion stats
  • 1 reply
  • 129 views
  • 0 likes
  • 2 in conversation