BookmarkSubscribeRSS Feed
knveraraju91
Barite | Level 11

Dear,

 

Thanks for your excellent support.

 

I am trying to create a variable from data1. But I am getting the output value for last OBS only. Why. Please help. Thanks.

 

my code:

 

data one;
set data1;
if trta='75 mg' then trt='A';
if trta='150 mg' then trt='B';
if trta='300 mg' then trt='C';
if trta='TOTAL' then trt='D';
run;

 

data1;

ns        trta

50        100 mg

60         25 mg

70         125 mg

180        Total

 

my code:

data one;
set data1;
if trta='100 mg' then trt='A';
if trta='25 mg' then trt='B';
if trta='125 mg' then trt='C';
if trta='TOTAL' then trt='D';
run;

 

ouput getting:

 

ns        trta                             trt

50        100 mg                    

60         25 mg

70         125 mg

180        Total                          D

 

 

2 REPLIES 2
Reeza
Super User

Then pleas post the answer and mark the question solved. 

CFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1817 views
  • 0 likes
  • 2 in conversation