09-01-2017 09:10 AM
Is there a simple way to make a format thar simply concatinate two char variables?
Data could be like this:
I wish to use a format to the organisaton variable som I get this output:
Alternative set a constant value as a pre-fix on the organisation based on content in another variable.
Like this :
CASE WHEN town=HH
I can construct the code in different ways - but i prefer to output the logic as a format so the original data not is changed and i do not need an extra column.
Thanks in advance.
09-01-2017 10:32 AM
Formats are associated with single variables, not multiple.
I think that you may want to provide a little more detail or variability in your "example" as you have n in 4 different places so it isn't exactly clear which 'n' goes where.
If you want to display 'GGGG' as a specific string that does not change then you could build a data set from your example values useing string concatenation functions so you have values like:
GGGG abc GGGG
YYYY pd YYYY
and build a format from that data set. There are some other bits. But a format only assings one label text to any given value.
You cannot have format assign abc GGGG one time and pd GGGG another time. That will require creating an actual additional variable with concatenation.
09-01-2017 10:56 AM
The organisation coloums has huge amount af different content. so I need to put a constant string or combine with another coloumn dynamiccaly. I was thinlking about a function and create a format from that - but is not sure how to do it...
09-01-2017 11:25 AM
A format will only associate with a single variable. And only assign one output value for a given input (barring use of multilabel formats in the very small number of procedures that recognize them). Even though you can use a user function in a format it may only use one variable.
In effect you are asking to do something like this:
Proc format library=work; value $junk 'GGGG' = 'abc GGGG' 'GGGG' = 'pd GGGG' ; run;
which will result in a repeated range error.
19 Proc format library=work; 20 value $junk 21 'GGGG' = 'abc GGGG' 22 'GGGG' = 'pd GGGG' ERROR: This range is repeated, or values overlap: GGGG-GGGG. 23 ; NOTE: The previous statement has been deleted. 24 run;