BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Samero
Obsidian | Level 7

I have a table like this

Ac1               Ac2       Ac3     ZDS

Stoffwechsel Cycle    osg      9.05.02.

Stoffwechsel Cycle    osh      9.05.02.

Stoffwechsel Cycle                9.05.02.

Stoffwechsel Cycle    osg      9.05.02.

 

I just want from SAS to replace the ZDS value when Ac2 = Cycle  and Ac3 is missing at the same time (in this cas at the third line), How to do that what to write in SAS?

I tried

if Ac2 = Cycle   and Ac3 = " " then ZDS = 9.05.04.;

run;

but it didn"t work

Many thanks in advance             

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11

Try :

if Ac2 = 'Cycle'   and missing(Ac3)  then ZDS = "9.05.04.";

View solution in original post

7 REPLIES 7
r_behata
Barite | Level 11

Try :

if Ac2 = 'Cycle'   and missing(Ac3)  then ZDS = "9.05.04.";
Samero
Obsidian | Level 7
wow, that worked super, thank you very much
Samero
Obsidian | Level 7
but what if it is not a missing value and i wanted to change the third value based on the first two values what will be the code in this case? many thanks
ballardw
Super User

Is ZDS supposed to be a SAS DATE value? (if so really should use a 4 digit year display format)

 

The only way to use a literal date value in SAS is to use the "ddMONyy"d or "ddMONyyyy"d construct.

So if you want a date that would be 9 May 2002 use "09May2002"d, if you want 5 Sep 2002 use "05Sep2002"d.

Choice of single or double quotes is yours.

Samero
Obsidian | Level 7
no it is not a date it is a key
andreas_lds
Jade | Level 19

Have you tried the code suggested by @r_behata ?

 

Samero
Obsidian | Level 7
yes, it has done the trick

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 7 replies
  • 1632 views
  • 2 likes
  • 4 in conversation