I am trying to make some data less identifiable by using a case/when/then statement so that values beneath $10,000 output as <$10,000. However, SAS errors as "Result of WHEN clause 2 is not the same data type as the preceding results" - i.e., I assume it is a text string and not a numeric value due to the "<" symbol.
Does anyone have any ideas of how to work around this? (Other than letting it equal an extremely specific number and then using formulae in Excel afterwards to target that value).
Example code in my PROC SQL statement below
Making values display differently is quite often the role of a custom format. Create an appropriate format and assign it when creating output such as with Proc Print, Report or other procedure.
A rough example:
proc format; value mydollar 0 -<10000 = "<$10,000" 10000 - high = [dollar12.] ; data example; input x; datalines ; 1 100 1900 12345678 ; proc print data=example; format x mydollar.; run;
There are many things that can be done with formats. One thing is you can specify a format in different calls using the same data to see the effect. Groups created by formats will be honored by reports, analysis and most graphing activities.
Making values display differently is quite often the role of a custom format. Create an appropriate format and assign it when creating output such as with Proc Print, Report or other procedure.
A rough example:
proc format; value mydollar 0 -<10000 = "<$10,000" 10000 - high = [dollar12.] ; data example; input x; datalines ; 1 100 1900 12345678 ; proc print data=example; format x mydollar.; run;
There are many things that can be done with formats. One thing is you can specify a format in different calls using the same data to see the effect. Groups created by formats will be honored by reports, analysis and most graphing activities.
Thank you very much 🙂 Greatly appreciated!
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.