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

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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