BookmarkSubscribeRSS Feed
Shuail_Ibrahim
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

2 REPLIES 2
Tom
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.

Ksharp
Super User

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

 

data have;
input id $ test1-test4;
cards;
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};
end;
drop i t1-t4;
run;

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 2723 views
  • 0 likes
  • 3 in conversation