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

I want to append all dataset into one (using proc append) I'm using below code, but not giving output

 

Please help !!

 


proc sql;
select count(*) into : obs from sashelp.vtable
where libname = 'ABC';

%LET OBS=&OBS;
SELECT memname INTO : TAB1-:TAB&OBS FROM sashelp.vtable
where libanme = 'ABC';

QUIT;

%MACRO append;
%DO i=1 %to &obs;
proc append base=tot_comb data=&&tab&i force;run;
%end;
%mend;

%append;

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Uh...you should probably fix those errors from the first proc? 

 

Take a a look at the table and and make sure your query is correct. I'm not in front of a computer with SAS to answer the actual column name. 

View solution in original post

6 REPLIES 6
Reeza
Super User

Are you getting errors? 

 

Pleae explain how it isn't working. 

 

Make sure to ru it with mprint symbolgen on to see what's happening. 

atul_desh
Quartz | Level 8

 

 

809 proc sql;
810 select count(*) into : obs from sashelp.vtable
811 where libname = 'ABC';
812 %LET OBS=&OBS;
SYMBOLGEN: Macro variable OBS resolves to 3
813 SELECT memname INTO : TAB1-:TAB&OBS FROM sashelp.vtable
SYMBOLGEN: Macro variable OBS resolves to 3
814 where libanme = 'ABC';
ERROR: The following columns were not found in the contributing tables: libanme.
815 QUIT;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.13 seconds
cpu time 0.03 seconds

816 %MACRO append;
817 %DO i=1 %to &obs;
818 proc append base=tot_comb data=&&tab&i force;run;
819 %end;
820 %mend;
821 %append;
MLOGIC(APPEND): Beginning execution.
SYMBOLGEN: Macro variable OBS resolves to 3
MLOGIC(APPEND): %DO loop beginning; index variable I; start value is 1; stop value is 3; by value is
1.


SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
NOTE: Line generated by the macro variable "I".
1 &tab1
-
22
200
WARNING: Apparent symbolic reference TAB1 not resolved.
ERROR: File WORK.TAB1.DATA does not exist.
MPRINT(APPEND): proc append base=tot_comb data=&tab1 force;
MPRINT(APPEND): run;

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.02 seconds
cpu time 0.01 seconds

NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(APPEND): %DO loop index variable I is now 2; loop will iterate again.


SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 2
NOTE: Line generated by the macro variable "I".
1 &tab2
-
22
200
WARNING: Apparent symbolic reference TAB2 not resolved.
ERROR: File WORK.TAB2.DATA does not exist.
MPRINT(APPEND): proc append base=tot_comb data=&tab2 force;
MPRINT(APPEND): run;

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(APPEND): %DO loop index variable I is now 3; loop will iterate again.


SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 3
NOTE: Line generated by the macro variable "I".
1 &tab3
-
22
200
WARNING: Apparent symbolic reference TAB3 not resolved.
ERROR: File WORK.TAB3.DATA does not exist.
MPRINT(APPEND): proc append base=tot_comb data=&tab3 force;
MPRINT(APPEND): run;

ERROR 22-322: Expecting a name.

ERROR 200-322: The symbol is not recognized and will be ignored.

NOTE: Statements not processed because of errors noted above.
NOTE: PROCEDURE APPEND used (Total process time):
real time 0.01 seconds
cpu time 0.00 seconds

NOTE: The SAS System stopped processing this step because of errors.
MLOGIC(APPEND): %DO loop index variable I is now 4; loop will not iterate again.
MLOGIC(APPEND): Ending execution.

 

Reeza
Super User

Uh...you should probably fix those errors from the first proc? 

 

Take a a look at the table and and make sure your query is correct. I'm not in front of a computer with SAS to answer the actual column name. 

atul_desh
Quartz | Level 8
yeah...i got the output..thanks...but just a quick question (I was missing that base table should have same schema similar to data from which i'm appending) :

proc sql;
select count(*) into : obs from sashelp.vtable
where libname = 'ABC';
%LET OBS=&OBS;
SELECT catx('.', 'abc', memname) INTO : TAB1-:TAB&OBS FROM sashelp.vtable
where libname = 'ABC';
QUIT;
%MACRO append;
%DO i=1 %to &obs;
proc append base=tot_comb data=&&tab&i force;run;
%end;
%mend;
%append;

proc print data=tot_comb;
run;
atul_desh
Quartz | Level 8

sorry...Its working !!

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
  • 6 replies
  • 7104 views
  • 0 likes
  • 3 in conversation