DP
2007-10-30 18:50:58 UTC
Hi,
Can anyone help me with this.
I am trying to concatenate 6 different variables seperated by a comma in
between them. The only thing I want is that the non missing values of the
variables should be concatenated.
I have already tried the concatenation operator to combine them but does
not seem to work. It concatenates the missing values also, which I do not
want to show.
I tried something like this:
NEW_VAR=VAR1||','||VAR2||','||VAR3||','||VAR4||','||VAR5||','||VAR6;
and gives output like:
NEW_VAR= , ,XX, , ,YY;
Consider example:
GIVEN DATASET:
IDNO VAR1 VAR2 VAR3 VAR4 VAR5 VAR6
1 AA BB CC DD EE
2 AB AC AD AE
3 BC BD BE BF
4 MM MA MB MC MD ME
5 DD DM
OUTPUT WANTED:
IDNO VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 NEW_VAR
1 AA BB CC DD EE AA,BB,CC,DD
2 AB AC AD AE AB,AC,AD,AE
3 BC BD BE BF BC,BD,BE,BF
4 MM MA MB MC MD ME MM,MA,MB,MC,MD,ME
5 DD DM DD,DM
HELP GREATLY APPRECIATED.
THANKS.
DP
Can anyone help me with this.
I am trying to concatenate 6 different variables seperated by a comma in
between them. The only thing I want is that the non missing values of the
variables should be concatenated.
I have already tried the concatenation operator to combine them but does
not seem to work. It concatenates the missing values also, which I do not
want to show.
I tried something like this:
NEW_VAR=VAR1||','||VAR2||','||VAR3||','||VAR4||','||VAR5||','||VAR6;
and gives output like:
NEW_VAR= , ,XX, , ,YY;
Consider example:
GIVEN DATASET:
IDNO VAR1 VAR2 VAR3 VAR4 VAR5 VAR6
1 AA BB CC DD EE
2 AB AC AD AE
3 BC BD BE BF
4 MM MA MB MC MD ME
5 DD DM
OUTPUT WANTED:
IDNO VAR1 VAR2 VAR3 VAR4 VAR5 VAR6 NEW_VAR
1 AA BB CC DD EE AA,BB,CC,DD
2 AB AC AD AE AB,AC,AD,AE
3 BC BD BE BF BC,BD,BE,BF
4 MM MA MB MC MD ME MM,MA,MB,MC,MD,ME
5 DD DM DD,DM
HELP GREATLY APPRECIATED.
THANKS.
DP