I tried both.
no difference
try another variant:
data want;
set have;
if col1>. then col2='Y';*if col1 is numeric;
/*if col1>' ' then col2='Y';*if col1 is character;*/
run;
no luck!! 😞
I am afraid you really need to share the best sample of what dataset you have for the community to test. More exact or close to being exact will help
@hashman Boss, Sorry for my response in later part of the thread (deliberately). The reason is, I tried to suggest OP all that came to my mind. And for whatever reason OP has responded saying unsuccessful. Even to the previous one just before this. Apparently, so simple thread had extended too long and is still open 😞
data want;
set have;
if col1>. then col2='Y';*if col1 is numeric;
/*if col1>' ' then col2='Y';*if col1 is character;*/
run;
@novinosrin, Yeah, Chief, it's become kind of protracted. Occassinally, OPs have a vague idea what they want and/or express their wishes incompletely or ambiguously ;).
Paul D.
col2 | ||
1 | ||
2 | 25 |
|
3 | ||
4 | ||
6 | 29 |
|
7 | ||
9 |
col2 | ||
1 | ||
2 | 25 | Y |
3 | ||
4 | ||
6 | 29 | Y |
7 | ||
9 |
I want to go from first data set to the second one. let's call the third column "col3"
Thanks,
Nazanin
data two ;
set one ;
if not missing (col2) then col3 = "Y" ;
run ;
Paul D.
Thanks a lot Paul,
It works. If I want to update on the same dataset, is it possible? also if I have more than one column to update, can I do at the same time?
so basically I want to expand the code to go from table one to table 2.
col1 | dis1 | dis2 | dis3 | DIS | VisCode | Vis | InCode | In |
1 | ||||||||
2 | 3 | 2 | ||||||
3 | 6 | |||||||
4 | 5 | |||||||
5 | 5 | |||||||
6 | ||||||||
7 | 7 |
col1 | dis1 | dis2 | dis3 | DIS | VisCode | Vis | InCode | In |
1 | ||||||||
2 | 3 | Y | 2 | Y | ||||
3 | 6 | Y | ||||||
4 | 5 | Y | ||||||
5 | 5 | Y | ||||||
6 | ||||||||
7 | 7 | Y |
if I do each update separately, I lose the previous update. How can I do all together?
Your help is much appreciated.
best,
Nazanin
Hi Paul,
This is what I figured it out:
data updateSI2 ;
set SINewCol ;
if not missing (DIS1) or not missing(DIS2) or not missing (DIS3) or not missing (DIS4) or not missing (DIS5) or
not missing (DIS6) or not missing(DIS7) or not missing(DIS8) or not missing(DIS9)then PWD = "Y";
if not missing (AborCode) then Abor="Y";
if not missing ( VisCode) then VisMin="Y"
;
run ;
now I'm working on making it shorter!
best regards,
Nazanin
@NazaninSAS, this is not an error. It is a note. You can read more about that particular note in a related thread here.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.