0

Is it possible to write a condition inside a cats() function?

Something like this:

data ...
   ...
   line2=cats('xxxx',if (severity=.) then 'missing' else severity,'yyyyy');
   ...

I would like to do this in order to write a json file. Because severity is a numeric variable, when it's missing it's a . and that create invalid json files. I'm searching for a way to replace these dots with a string in the json like e.g. 'missing' in my example.

EDIT: Forgot to say I'm in a data step here

stallingOne
  • 3,633
  • 3
  • 41
  • 63

1 Answers1

3

Why not just use the IFC() function?

ifc(severity=.,'missing',put(severity,best12.))

Of define a format.

proc format ;
  value severity .='missing' other=[best12.];
run;
...
line2=cats('xxxx',put(severity,severity.),'yyyyy')
Tom
  • 47,574
  • 2
  • 16
  • 29