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

I had some random data in that data i want to add some data in between that already existed data by using under EmpID.

 

data Examplex;
	input EmpID $ Name $ Designee $ 27-39 Department $;
	datalines;
		101		Madhu     Jr Associate    QA
		103		Sathwik   Jr Associate    PB
		104		Mohan     Manager         PB
		106		Raja      Manager         QA
		107		Kiran     Manager         BR
		108		Sainath   Manager         CL
		;
run;

proc print data = Examplex;
run;

 

We want to add data which is given below

 

102		Satya	Sr Associate	PB
105		Sai		Trinee			BR
109		Surya	Manager			CL

I'm expecting this out put.

jfvnj.jpg

thank you

Sathwik 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

Hello,

 

data Examplex;
	input EmpID $ Name $ Designee $ 27-39 Department $;
	datalines;
		101		Madhu     Jr Associate    QA
		103		Sathwik   Jr Associate    PB
		104		Mohan     Manager         PB
		106		Raja      Manager         QA
		107		Kiran     Manager         BR
		108		Sainath   Manager         CL
		;
run;

data new;
	input EmpID $ Name $ Designee $ 27-39 Department $;
	datalines;
        102     Satya     Sr Associate    PB
        105     Sai       Trinee          BR
        109     Surya     Manager         CL
        ;
run;

data want;
    merge Examplex new;
    by EmpID;
run;

View solution in original post

4 REPLIES 4
gamotte
Rhodochrosite | Level 12

Hello,

 

data Examplex;
	input EmpID $ Name $ Designee $ 27-39 Department $;
	datalines;
		101		Madhu     Jr Associate    QA
		103		Sathwik   Jr Associate    PB
		104		Mohan     Manager         PB
		106		Raja      Manager         QA
		107		Kiran     Manager         BR
		108		Sainath   Manager         CL
		;
run;

data new;
	input EmpID $ Name $ Designee $ 27-39 Department $;
	datalines;
        102     Satya     Sr Associate    PB
        105     Sai       Trinee          BR
        109     Surya     Manager         CL
        ;
run;

data want;
    merge Examplex new;
    by EmpID;
run;
sathwik
Calcite | Level 5
Suppose without any "Emp ID" how to put data at particular possession
gamotte
Rhodochrosite | Level 12

If by position, you mean row number, you can use _N_ to get the currently processed row index

and, when the condition is met, read data from your alternate dataset :

 

data want;
    set Examplex;
    output;

    if _N_=5 then do until(eof);
        set new end=eof;
        output;
    end;
run;
sathwik
Calcite | Level 5
Thank you
Sathwik

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1086 views
  • 0 likes
  • 2 in conversation