Help using Base SAS procedures

proc sql insert new record

Accepted Solution Solved
Reply
Super Contributor
Posts: 301
Accepted Solution

proc sql insert new record

                 Obs   drug      placebo     total   col0

                1           14.76% 00.00% 12.50%Latin
                2 13   61.90%11   57.89%24   60.00%Caucasian
                7   33.33% 7   36.84%14   35.00%Black
                00.00% 15.26% 12.50%Asian

Hi guys, sorry for the mess of the table have, but i am interested in the last variable (col0) with the value (Latin, Cauc. Black and Asian), and

I am interesting to add a new record heading this table as:

col0='Race' , drug= ' ' , placebo=' ', total=' '

I try the next syntax using INSERT in proc sql (I want to do it in proc qsl) but it doesnt work...any help?

proc sql;

*Add new record;

insert into have

set col0='Race',

Drug=' ',

Placebo=' ',

from have ;

quit;

Thanks.


Accepted Solutions
Solution
‎06-07-2012 12:09 PM
Regular Contributor
Posts: 184

Re: proc sql insert new record

That only works because all of the affected columns are of character type, and sufficiently wide.

It looks like you are just tweaking headings for display. You should be able to do that with a simple LABEL= spec, as in

  select

   ...

   col0 label='Race'

   ...

   from

   ... ;

michtka wrote:

I got it:

proc sql;

*Add new record;

insert into tablec1

(Drug,Placebo, total, Col0)

values

(' ',' ', ' ', 'Race');

quit;

Thanks.

View solution in original post


All Replies
Super Contributor
Posts: 301

Re: proc sql insert new record

I got it:

proc sql;

*Add new record;

insert into tablec1

(Drug,Placebo, total, Col0)

values

(' ',' ', ' ', 'Race');

quit;

Thanks.

Solution
‎06-07-2012 12:09 PM
Regular Contributor
Posts: 184

Re: proc sql insert new record

That only works because all of the affected columns are of character type, and sufficiently wide.

It looks like you are just tweaking headings for display. You should be able to do that with a simple LABEL= spec, as in

  select

   ...

   col0 label='Race'

   ...

   from

   ... ;

michtka wrote:

I got it:

proc sql;

*Add new record;

insert into tablec1

(Drug,Placebo, total, Col0)

values

(' ',' ', ' ', 'Race');

quit;

Thanks.

Super Contributor
Posts: 301

Re: proc sql insert new record

Sorry Howles, I saw your answer as correct, but it not, because with col0 label='Race', you change the name of the variable,

when i am not interested in this, I want a new record called 'sex' as another value of the variable col0.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 467 views
  • 0 likes
  • 2 in conversation