Documentation for the SET statement (https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/p00hxg3x8lwivcn1f0e9axziw57y.htm) describes that SET is used to read observations, not to create a data set. What is your definition of a "temporary data set?" A common working definition is a "data set not saved when the SAS session terminates," and these "temporary data sets" can be created in the WORK library, as its contents are not saved across (or after) SAS sessions. Whenever a data set is created (or otherwise referenced), and no SAS library is explicitly denoted (in dot notation like LIBRARY.DATASET), then the WORK library is applied by default (i.e., WORK.DATASET). For example, your Hosp data set is temporary because no library is specified when Hosp is created, so the data set you have created is WORK.Hosp. Thus, to create a temporary data set Hosp2, you need to only need to reference Hosp2 in the DATA statement: data Hosp2;
... View more