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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 4 replies
  • 896 views
  • 0 likes
  • 2 in conversation