PROC SQL - concat a field with num type with field with char type

PROC SQL - concat a field with num type with field with char type

Post by lleem » Fri, 02 Aug 2002 00:55:54



I have the following script:
LIBNAME mylib '/data';

proc sql outobs=10;
select OTB || '|' acctno
from mylib.acct;

I keep getting an error due to OTB being of type Num.  How can I
concatenate a num field with a character field using PROC SQL?

Thanks for anyone that can help.

 
 
 

PROC SQL - concat a field with num type with field with char type

Post by Prasad Ra » Fri, 02 Aug 2002 01:08:07


        You cannot,  unless you want to convert the numeric field to
character and then do the concatenation.

proc sql outobs=10;
select put(OTB,8.) || '|' acctno
from mylib.acct;

Prasad Ravi



                        OM>                    Subject:    PROC SQL - concat a field with num type with field with
                        Sent by: "SAS(r)              char type
                        Discussion"

                        GA.EDU>

                        07/31/2002 08:55
                        AM
                        Please respond to
                        lleemon

I have the following script:
LIBNAME mylib '/data';

proc sql outobs=10;
select OTB || '|' acctno
from mylib.acct;

I keep getting an error due to OTB being of type Num.  How can I
concatenate a num field with a character field using PROC SQL?

Thanks for anyone that can help.

 
 
 

PROC SQL - concat a field with num type with field with char type

Post by Kevin Mye » Fri, 02 Aug 2002 01:14:48


Use the PUT function to convert your numeric OTB variable to a character
representation prior to concatenation.

s/KAM

----- Original Message -----

Newsgroups: bit.listserv.sas-l

Sent: Wednesday, July 31, 2002 10:55 AM
Subject: PROC SQL - concat a field with num type with field with char type

> I have the following script:
> LIBNAME mylib '/data';

> proc sql outobs=10;
> select OTB || '|' acctno
> from mylib.acct;

> I keep getting an error due to OTB being of type Num.  How can I
> concatenate a num field with a character field using PROC SQL?

> Thanks for anyone that can help.

 
 
 

PROC SQL - concat a field with num type with field with char type

Post by Laurel A. Copela » Fri, 02 Aug 2002 02:35:25


you can convert with PUT()
e.g.,

data try;
 input sta5a $5. pstachy 1. VX1 $ VX2 $ numb 2.;
cards;
101A 1 1A 2A 21
101AB0 2B 3B 34
102  1 3C 4C 78
103GA1 1B 2B 61
104  1 2C 3C 46
158YZ0 3D 4D 07
;
run;

proc sql outobs=10;
select PUT(numb,best.) || '|' || vx1
from try; quit;

hth, laurel (ann arbor VA)

 
 
 

1. PROC SQL and Compressing a field to create another field

To The Speedy SAS-l Readers:
Thank you very much for taking the time to answer my question. The solution
was a true success. This was my first posted question and I can't believe
the response time from everyone.

Sincerely,

James Blaha

Subject: RE: PROC SQL and Compressing a field to create another field

2. Ghost image between NTFS and FAT32

3. Na na na na, na na na na....

4. Year 2000

5. SQL-Programmer tool and field%type support

6. Double Buffering

7. ANY GAMES COMPANIES NEAR LEEDS? - PLEASE READ

8. Setting sql table field data-types?

9. setsockopt() - IP Type of Service field

10. Format type of a text field

11. SAS/AF - How to determine the assigned field type with code in the PROGRAM section?

12. Error on data-base field named TYPE