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

HelloI want to  merge these data with a macro.I also wish to create a variable call locate such that as it is stacking the data set ampute_1 - ampute_20; this variable that I will call "LOCATE" should be 1 for all all data from ampute_1, 2 for all data from

ampute_2 etc

THat is

Variable

X y   Locate

1  2    1

3  2    1  {ampute_1}

3 1     1


2 2     2 

1 4    2

4  1   2{ampute_2}

ETC

This is the code that need correction.

data impute_t_&p;

set ampute_1 - ampute_20;

if Sim lt 4 then delete;

run;

1 ACCEPTED SOLUTION

Accepted Solutions
Jagadishkatam
Amethyst | Level 16

Please try the below code,

data ampute_1;

    input X y;

cards;

1  2  

3  2  

3 1   

;

data ampute_2;

    input x y;

cards;

2 2    

1 4   

4  1  

;

%macro test();

data ampute_final;

    set

    %do i = 1 %to 2;

    ampute_&i(in=a&i)

    %end;

    ;

    %do i = 1 %to 2;

    if a&i then locate=&i;

    %end;

run;

%mend;

%test();

Thanks,

Jagadish

Thanks,
Jag

View solution in original post

2 REPLIES 2
Jagadishkatam
Amethyst | Level 16

Please try the below code,

data ampute_1;

    input X y;

cards;

1  2  

3  2  

3 1   

;

data ampute_2;

    input x y;

cards;

2 2    

1 4   

4  1  

;

%macro test();

data ampute_final;

    set

    %do i = 1 %to 2;

    ampute_&i(in=a&i)

    %end;

    ;

    %do i = 1 %to 2;

    if a&i then locate=&i;

    %end;

run;

%mend;

%test();

Thanks,

Jagadish

Thanks,
Jag
desireatem
Pyrite | Level 9

I want introduce u in this macro such that the last data should be by U:

.........

........

Matrix=matrix//temp;

end; matrix=matrix[2:nrow(matrix),];

create impute_tt_&u var{obs censored time Y timeS  X sim };

      append from matrix;

quit;

%end;

data impute_t_&p;;

set

%do u = 1 %to 5;

impute_tt_&u(in=a&u)

%end;

;

%do u = 1 %to 5;

if a&u then locate=&u;

%end;

run;

.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 2 replies
  • 494 views
  • 1 like
  • 2 in conversation