The script begins by attempting to delete a table named 'new1' in the 'mydblib' library. Then, a first DATA STEP tries to create 'mydblib.new1' from 'work.new', which will fail because 'work.new' does not yet exist. The script corrects this by creating 'work.new' with a simple variable 'x'. After this creation, a second DATA STEP successfully creates 'mydblib.new1' from 'work.new'. Finally, the 'mydblib.new1' table is deleted again. The main objective is to demonstrate conditional table creation logic and error handling related to data sources.
Data Analysis
Type : INTERNAL_CREATION
The data used ('work.new') is created directly within the script via a DATA STEP. The 'mydblib' library is a reference to an external library (Impala in the original comment's context), but the 'new1' data is generated and manipulated within this environment, without dependence on unmanaged external files.
1 Code Block
PROC DELETE
Explanation : This block attempts to delete the 'new1' table in the 'mydblib' library. This is an initial cleanup operation or handling cases where the table might already exist.
Copied!
proc delete data=mydblib.new1;
run;
1
PROC DELETEDATA=mydblib.new1;
2
RUN;
2 Code Block
DATA STEP
Explanation : This DATA STEP attempts to create the 'mydblib.new1' table by reading data from the temporary dataset 'work.new'. At this stage of the script, 'work.new' does not exist, so this block is intended to fail and illustrates an error scenario.
Copied!
data mydblib.new1;
set work.new;
run;
1
DATA mydblib.new1;
2
SET work.new;
3
RUN;
3 Code Block
DATA STEP Data
Explanation : This DATA STEP creates the temporary dataset 'work.new' with a single observation and a variable 'x' with the value 1. This step is crucial for the subsequent DATA STEP to execute correctly.
Copied!
data work.new;
x=1;
run;
1
DATA work.new;
2
x=1;
3
RUN;
4 Code Block
DATA STEP Data
Explanation : After 'work.new' is created, this DATA STEP successfully creates 'mydblib.new1' by copying data from 'work.new'. This demonstrates the success of the operation after resolving the data source dependency.
Copied!
data mydblib.new1;
set work.new;
run;
1
DATA mydblib.new1;
2
SET work.new;
3
RUN;
5 Code Block
PROC DELETE
Explanation : This block deletes the 'new1' table from 'mydblib' again, completing the test cycle by cleaning up the created table.
Copied!
proc delete data=mydblib.new1;
run;
1
PROC DELETEDATA=mydblib.new1;
2
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.