BookmarkSubscribeRSS Feed
Calcite | Level 5

How to replace if the value is 1 with the below row value "Weight" find the below image current data set and the final output required,

please any one help how to get the final required datasetdataheloset.PNG

Super User Tom
Super User

Why did you post photographs of 25 numbers? Wouldn't it have been easier to just type (or paste) the numbers directly into your question?  It certainly would be easier to deal with.


First step is the split the original mish-mash into two datasets.  One with the actual employee data. And the other with the WEIGHT data.  Now you can combine them.  It looks like you just want to multiple the value of TEST1 times the value of WEIGHT1, TEST2 times the value of WEIGHT2 etc. Do not attempt to add the extra row back into the result.  If you need to re-create your photograph do that as a report.

Super User

Plz post the data step code ,NOT picture , nobody would like to type it for you.


data have;
input id $ test1-test4;
1 0 0 0 1
2 1 0 0 0
3 0 0 1 0
4 0 0 0 0
weight 1.412 0.207 0.207 0.207
data want;
 set have;
 if _n_=1 then set have(keep=test1-test4 
 rename=(test1-test4=t1-t4)) point=nobs nobs=nobs;
array x{*} test1-test4;
array y{*} t1-t4;
do i=1 to dim(x);
 if x{i} then x{i}=y{i};
drop i t1-t4;



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 3 in conversation