Hi, I have some questions about these two steps.
1. Is there any other steps in SAS other than Date Step and Proc Step?
2. If the step begins with Data then it's a Data step and if it begins with PROC then it is a PROC step?
3. Is PROC SQL considered as a PROC step?
4. PDV and the two automatic variables _N_ and _ERROR_, are only available in Date steps or in any SAS program or steps?
@cosmid wrote:
Hi, I have some questions about these two steps.
Here are some of my opinions
1. Is there any other steps in SAS other than Data Step and Proc Step?
I don't think so. Unless you may want to define any open code/global statements that is processed by the macro processor and compiler respectively as an exclusive step of its own making it the third one.
2. If the step begins with Data then it's a Data step and if it begins with PROC then it is a PROC step?
I think that's correct at least that's how it is portrayed in docs
3. Is PROC SQL considered as a PROC step?
I suppose PROC is a keyword that stands for procedure. So, yes a procedure that invokes sql should indeed be considered PROC step until you "quit;" the procedure 🙂
4. PDV and the two automatic variables _N_ and _ERROR_, are only available in Date steps or in any SAS program or steps?
Yes for the reason _N_ is an automatic variable that takes the values soon as datastep execution loops past the data statement and I don't think this facility is available in a proc. Both these are created in the PDV at compile time
@cosmid wrote:
Hi, I have some questions about these two steps.
Here are some of my opinions
1. Is there any other steps in SAS other than Data Step and Proc Step?
I don't think so. Unless you may want to define any open code/global statements that is processed by the macro processor and compiler respectively as an exclusive step of its own making it the third one.
2. If the step begins with Data then it's a Data step and if it begins with PROC then it is a PROC step?
I think that's correct at least that's how it is portrayed in docs
3. Is PROC SQL considered as a PROC step?
I suppose PROC is a keyword that stands for procedure. So, yes a procedure that invokes sql should indeed be considered PROC step until you "quit;" the procedure 🙂
4. PDV and the two automatic variables _N_ and _ERROR_, are only available in Date steps or in any SAS program or steps?
Yes for the reason _N_ is an automatic variable that takes the values soon as datastep execution loops past the data statement and I don't think this facility is available in a proc. Both these are created in the PDV at compile time
Agreed, with a little detail to add.
Global statements include non-macro statements such as TITLE and OPTION statements. Technically those are not part of a DATA or PROC step. However, they are not considered a "step", merely a "statement" that remains in effect until changed later.
Yep and indeed true. I should have mentioned a clause with question mark(?) 🙂
Thank you so much guys! That really helped me understand things better!
One last question, but _N_ and _ERROR_ are available for PROC IMPORT? Since PROC IMPORT also creates a PDV? The book wasn't very clear on PROC IMPORT. Here's all the contents the book has on PROC IMPORT, it's right after the Iteration of the Data Step section, under a PDV figure and a SAS Data Set Output, so I'm assuming it also has a PDV?
When PROC IMPORT reads raw data, SAS sets the value of each variable in the DATA step to missing at the beginning of each cycle of execution, with these exceptions:
1. variable that are named in a RETAIN statement
2. variables that are created in a sum statement
3. automatic variables
In Contrast, when reading variables from a SAS data set, SAS sets the values to missing only before the first cycle of execution of the DATA step. Therefore, the variables retain their values until new values become available(for example, through an assignment statement or through the next execution of a SET or MERGE statement). Variables that are created with options in a SET or MERGE statement also retain their values from one cycle of execution to the next.
I'm also assuming the second paragraph is still referring to PROC IMPORT.
1.So does this mean that PDV and the two automatic variables _N_ and _ERROR_ are created in all DATA Steps and also created in PROC IMPORT but not other PROC Steps?
2.The key difference between PROC IMPORT and a DATA Step is when reading SAS data sets, PROC IMPORT retains the value until new values are available while DATA Step resets the values to missing in each new iteration?
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.