BookmarkSubscribeRSS Feed
RamKumar
Fluorite | Level 6

I need to understand the SAS code to copy the column value from one to other like below.

Assume i've a table called 'one' with values like below.

a b

1 2

3 4

5 6

I need to copy the column values from a to b and the output should be like

a b

1 1

3 3

5 5

Please suggest the SAS code to achieve this.

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well I assume b in the second table is b from the first table - 1 so:

data want (rename=(new_b=b));

     set have;

     new_b=b-1;

run;

hello_fj
Calcite | Level 5

I think we shoud assign value of vara to  varb  just like this

data want;

set have;

b=a;

run;

ShreyasTare
Calcite | Level 5

If A and B column both are in same table then you can try following code :

 

data want;
set have;
array new{1} a;
b = sum(of new{*});
run;

 

P.S. : I don't think its a proper way to copy columns though!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 10517 views
  • 0 likes
  • 4 in conversation