Hello,
I would like to add value to an existing row.
For example, I have a table,
data mydata;
input num1 num2 mydate date9.;
format mydate date9.;
datalines;
1200 50000 05MAY1985
0 0 17AUG1982
1500 43500 23OCT1991
;
run;
the output:
1200 | 50000 | 05MAY1985 |
0 | 0 | 17AUG1982 |
1500 | 43500 | 23OCT1991 |
The second row has 0 and 0. I want to change 0,0 to 1700, 60000. Can I do that use SAS?
Thank you all,
JH
Sounds like you want to use the Modify Statement
@jhusoc wrote:
Hello,
I would like to add value to an existing row.
For example, I have a table,
data mydata; input num1 num2 mydate date9.; format mydate date9.; datalines; 1200 50000 05MAY1985 0 0 17AUG1982 1500 43500 23OCT1991 ; run;
the output:
Obs num1 num2 mydate123
1200 50000 05MAY1985 0 0 17AUG1982 1500 43500 23OCT1991 The second row has 0 and 0. I want to change 0,0 to 1700, 60000. Can I do that use SAS?
Thank you all,
JH
In your "real" data is it only one record or multiple that need this change?
If more than one record, do they all have the same change or different?
Do you have a variable, or combination of variables, that uniquely identify this record (or other records that need change)?
Hi jhusoc,
This may not be the most efficient way to do it, but it is perhaps the simplest:
data mydata;
input num1 num2 mydate date9.;
format mydate date9.;
datalines;
1200 50000 05MAY1985
0 0 17AUG1982
1500 43500 23OCT1991
;
data mydata;
set mydata;
if _n_=2 then
do;
num1 = 1700;
num2 = 60000;
end;
run;
Hope this helps.
Probably not what you need, but since you haven't explained your need on the full data set, this does what you asked for:
data mydata;
input NUM1 NUM2 MYDATE date9.;
format MYDATE date9.;
if NUM1=0 then NUM1=1700;
if NUM2=0 then NUM1=60000;
datalines;
1200 50000 05MAY1985
0 0 17AUG1982
1500 43500 23OCT1991
run;
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.
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.