BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
me55
Quartz | Level 8

i have some code here...

 

data weight;

     input IDNUMBER $ Week1 Week2;

     WeightLoss2=Week1-Week2;

     datalines;

2477 195 163

2431 220 198

2456 173 155

2412 135 116

;

 

proc sql;

alter table weight add DELETE char(2), DEL2  char(2);

quit;

 

data weight;

  set weight;

     if WeightLoss2>20 then DELETE='Y';

     else DELETE='N';

run;

 

proc print data=weight;

run;

 

okay, so this code clearly creates a table and conditionally updates it.  notice i create two tables.  when i run the update, is it possible to update two columns at once either to the same value or another?  so...

 

data weight;

  set weight;

     if WeightLoss2>20 then DELETE='Y' and DEL2='Y';

     else DELETE='N' and DEL2='N';

run;

1 ACCEPTED SOLUTION

Accepted Solutions
SuryaKiran
Meteorite | Level 14

You can by using DO END;

data weight;

  set weight;

     if WeightLoss2>20 then DO;
                           DELETE='Y' ;
                            DEL2='Y';
                          END;

     else DO;
             DELETE='N' ;
             DEL2='N';
           END;

run;
Thanks,
Suryakiran

View solution in original post

2 REPLIES 2
SuryaKiran
Meteorite | Level 14

You can by using DO END;

data weight;

  set weight;

     if WeightLoss2>20 then DO;
                           DELETE='Y' ;
                            DEL2='Y';
                          END;

     else DO;
             DELETE='N' ;
             DEL2='N';
           END;

run;
Thanks,
Suryakiran
me55
Quartz | Level 8
yeah, right. thanks...

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 2 replies
  • 1809 views
  • 0 likes
  • 2 in conversation