Hii...
Can anyone tell me how to replace the observations of a particular variable in a data set.?
i think merge / update will work.
or if you can provide sample data and output (how you want) , that could be helpful in answering your question.
Hello Vish,
The question is "Create a new data and transform the values of 5 variables(weight, calories, Protein, fat, Satfat). Variables containing Value = 11 will be replaced by the Value of 3 ."
The solution I had tried is
data bittu.junkfood123;
set bittu.junkfood;
WEIGHT = 3;
replace all var {WEIGHT} where (WEIGHT==11);
run;
Iam getting error when I execute my code.
Hello vish,
The Problem that I had is "Create a new data and transform the values of 5 variables(weight, calories, Protein, fat, Satfat). Variables containing Value = 11 will be replaced by the Value of 3 ."
The code that I tried is
data bittu.junkfood123;
set bittu.junkfood;
WEIGHT = 3;
replace all var {WEIGHT} where (WEIGHT==11);
run;
but I am getting error when I execute this...
I will do something like
data bittu.junkfood123;
set bittu.junkfood;
IF WEIGHT = 11 THEN WEIGHT=3;
run;
Also if you want to do the same for this 5 variables you could use an array
data bittu.junkfood123;
set bittu.junkfood;
array vars{*} weight calories Protein fat Satfat;
do over vars;
if vars=11 then vars=3;
end;
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.