Hello
I wish in a PROC TABULATE add data outputs (OUT 😃 in an existing table, but keeping the data already present. Basically, to add the new data in the old table.
Is this possible? Is there an option to add in my OUT =?
Here's my code for my PROC TABULATE:
PROC TABULATE
DATA = WORK. OUT TABLEAU_GLOBAL_R6 IS WORK. TablesTABLEAU_R6;
VAR delai_moyen;
CLASS Type_Document / ORDER = UNFORMATTED MISSING;
CLASS date_mois / ORDER = UNFORMATTED MISSING;
TABLE / * ROW Statement * /.
date_mois,
* COLUMN Statement * /.
(Type_Document =' ') *(delai_moyen * Mean={LABEL=""});
;
RUN;
RUN; QUIT;
A big thank you to you.
In that case, I would save all of your result sets in its own library. Then, I would query dictionary.tables to gather all of the names of your results, while using the into: function in the query to get all of the names of the tables, separated by a space. Then, I would run a datastep to merge the datasets. Like such:
PROC SQL;
SELECT MEMNAME INTO: NEWVAR SEPARATED BY " " FROM DICTIONARY.TABLES WHERE LIBNAME = 'MYLIBRARY';
QUIT;
DATA ALLRESULTS;
SET ELIG.&NEWVAR;
RUN;
PROC SQL;
CREATE TABLE ALLRESULTS AS
SELECT * FROM TABLEAU_GLOBAL_R6
UNION ALL
SELECT * FROM TABLEAU_GLOBAL_R5
UNION ALL
SELECT * FROM TABLEAU_GLOBAL_R4;
QUIT;
In that case, I would save all of your result sets in its own library. Then, I would query dictionary.tables to gather all of the names of your results, while using the into: function in the query to get all of the names of the tables, separated by a space. Then, I would run a datastep to merge the datasets. Like such:
PROC SQL;
SELECT MEMNAME INTO: NEWVAR SEPARATED BY " " FROM DICTIONARY.TABLES WHERE LIBNAME = 'MYLIBRARY';
QUIT;
DATA ALLRESULTS;
SET ELIG.&NEWVAR;
RUN;
Elig is just the name of the library I was using. You can use any library name.
In the where clause of the sql statement, you can search for tables WHERE MEMNAME LIKE 'TablesTABLEAU%'; That should do the trick. OR just create another library with only your result sets. Either way.
Hi @PAULOM,
I unmarked your solution and marked @thomp7050's solution as correct, since that what you said helped you. Thanks for using the communities
Best,
Shelley
Combining data from different tables is the same regardless of the source of the table. It isn't quite clear what you want by you could:
Combine the data with a datastep (set, merge or possibly update), proc sql join or possibly Proc append. However the OUT= option on proc tabulate will replace an existingd data set.
Note that you can create multiple table statements within a single call to proc tabulate and all of the resulting tables will be in the OUT= dataset and there is a variable to indicate which table the output is from.
Examples of what you need to combine would be helpful
I would say the answer is NO. Just add another step to your program.
So if the goal is to append the reults from the proc tablulate that you just ran to a table named OUT.ALL_RUNS then you code will look like this.
proc tabulate out=todays_run ....
proc append base=out.all_runs data=todays_run;
run;
But I expect you will have trouble with that if the variables that PROC TABULATE creates depends on the values in the input data. For PROC APPEND (or any type of insert into existing table operation) to work the base dataset needs to have all of the variables.
You might have better results generating a summary of the data using PROC SUMMARY. You could then use PROC TABULATE to produce a nice report from that summary data and also append the summary data to your existing dataset.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.