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;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.