C1 C2 C3
1 4 5
Now, I want to make a new variable that reads '145'. I did as follows:
STRING V501_new (a9).
COMPUTE V501_new = CONCAT(qq01_new, qq02_new, qq04_new).
>Error # 4311 in column 55. Text: )
>The string argument required for the function specified was not supplied.
>Execution of this command stops.
EXECUTE.
any help with correct syntax, please? thanks in advance!
Are those variables string or numeric? If numeric, and you want a
numeric result, do not use CONCAT. Just do this:
compute newvar = c1*100 + c2*10 + c3.
If that is not what you want, please provide more detail--i.e., what
types of variables are C1-C3, and what type of variable do you want the
result to be.
>
> STRING V501_new (a9).
> COMPUTE V501_new = CONCAT(qq01_new, qq02_new, qq04_new).
>
>> Error # 4311 in column 55. Text: )
>> The string argument required for the function specified was not supplied.
>> Execution of this command stops.
> EXECUTE.
>
> any help with correct syntax, please? thanks in advance!
--
Bruce Weaver
bwe...@lakeheadu.ca
http://sites.google.com/a/lakeheadu.ca/bweaver/Home
"When all else fails, RTFM."
Thanks Sir for your help! my variables are numeric. So, when I used
your newvar command, it does that but not exactly what I wanted.
For instance, if I have 1 in C1, missing in C2, C3. I'd hope, newvar
should give me 1 but its gave me 0. Anyhow, I found the fix for that
compute newvar=sum(c1*100,c2*10,c3) instead of using + sign.
thanks again for prompt help!
btw, in the meanwhile I was using another way of doing that (little
more complicated!)
VECTOR v=v1 TO v3.
COMPUTE V3temp=0.
LOOP #cnt=1 TO 3.
IF ~MISSING(v(#cnt))V3temp=V3temp*10 + v(#cnt).
END LOOP.
apparently this also did exactly as concat would do but obviously your
idea was simpler
>On Aug 12, 11:11�pm, Bruce Weaver <bwea...@lakeheadu.ca> wrote:
>> On 12/08/2011 5:55 PM, Manish Madan wrote:
>[snip, previous]
>Thanks Sir for your help! my variables are numeric. So, when I used
>your newvar command, it does that but not exactly what I wanted.
>
>For instance, if I have 1 in C1, missing in C2, C3. I'd hope, newvar
>should give me 1 but its gave me 0. Anyhow, I found the fix for that
You mean, "should give me 100"
>compute newvar=sum(c1*100,c2*10,c3) instead of using + sign.
I though you would need sum.1( ... ) to avoid the Missing problem;
but if it works, okay.
>
>thanks again for prompt help!
>
>btw, in the meanwhile I was using another way of doing that (little
>more complicated!)
>
>VECTOR v=v1 TO v3.
>COMPUTE V3temp=0.
>LOOP #cnt=1 TO 3.
>IF ~MISSING(v(#cnt))V3temp=V3temp*10 + v(#cnt).
>END LOOP.
>
>apparently this also did exactly as concat would do but obviously your
>idea was simpler
That would also yield "1" instead of "100" when the latter two are
missing. Also be careful and re-check the handling of Missing.
--
Rich Ulrich