BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
t_ar_taat
Quartz | Level 8

Hi!
I want to add new column to datasetA from another dataset(datasetB) in one step.

 

NOTE:
There’s no variable for merge.


From my google search,below information is hit,especially its title is so nice.

Adding One Value to All Records in a SAS® Data Set


But there’s no way for “by 1 step” or “in a data step”.


By now,I think “proc sql with alter” have possibility for it.
Or we can’t do it?

Because SAS’s help page for "alter" don’t have a example for it.

SAS help page of "alter in proc sql"

 

Someone please help me.
I introduce what I want to do with "2 step". 

data work.datasetB;
 var1="add this value for all obs";
 output;
run;

data work.datasetA;
 key=1;output;
 key=2;output;
 key=3;output;
run;

/* 1step */
data _null_ ;
 set datasetB;
 call symputx ('var1_value', var1) ;
 run ; 

/* 2step */
data work.datasetA;
 set work.datasetA;
 val1="&var1_value";
run;

Result

set_one_value_for_all_records

1 ACCEPTED SOLUTION

Accepted Solutions
t_ar_taat
Quartz | Level 8

Hi,ballardw

 

Thank you so much!!! so nice.

 

Have a nice day!

no_alter.jpg

View solution in original post

2 REPLIES 2
ballardw
Super User

proc sql;

   create table want as

   select datasetA.*, datasetB.*

   from dataset A, datasetB;

quit;

t_ar_taat
Quartz | Level 8

Hi,ballardw

 

Thank you so much!!! so nice.

 

Have a nice day!

no_alter.jpg

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1246 views
  • 0 likes
  • 2 in conversation