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

Hi all!

 

Regarding the lesson 1 programming 2 (Data step processing: Compilation).

The theory is:

 

"To build the PDV, SAS passes through the DATA step sequentially, adding columns and their attributes. The SET statement in this program is listed first, so all of the columns from the storm_summary_small table are added to the PDV along with the required column attributes name, type, and length.

If there are any other statements that define new columns, those columns are also added to the PDV. In this code, the LENGTH statement defines the character column Ocean with a length of 8. StormLength is the last new column, and based on the arithmetic expression, it's defined as a numeric column with a length of 8."

The lecture note is:

ResoluteCarbon_0-1617314719594.png

what I want to focus is the column "Basin". I am wondering why the column Basin is at this position. Because SAS will go through all the codes sequentially. So, they will exclude the old Basin and add a new Basin column at the end of the yellow table in PDV when stopping by the data statement 

Basin=upcase(Basin);

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Huh?

This statement

Basin=upcase(Basin);

is not going to make a new variable.  It is going the change the value of the current variable.

The only way it would make a new variable would be if BASIN had not been seen before.

 

If you look at the first three lines of the DATA step and the picture showing the order of the variables you can KNOW that BASIN was defined because it appeared in the input dataset.

 

Do you see why you can know that?

Spoiler
Ocean is the first variable mentioned explicitly in the code.  Since it is the 6th variable in the photograph of the order that means the five before it must have come from PG2.STORM_SUMMARY_SMALL.

View solution in original post

1 REPLY 1
Tom
Super User Tom
Super User

Huh?

This statement

Basin=upcase(Basin);

is not going to make a new variable.  It is going the change the value of the current variable.

The only way it would make a new variable would be if BASIN had not been seen before.

 

If you look at the first three lines of the DATA step and the picture showing the order of the variables you can KNOW that BASIN was defined because it appeared in the input dataset.

 

Do you see why you can know that?

Spoiler
Ocean is the first variable mentioned explicitly in the code.  Since it is the 6th variable in the photograph of the order that means the five before it must have come from PG2.STORM_SUMMARY_SMALL.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
LIBNAME 101

Follow along as SAS technical trainer Dominique Weatherspoon expertly answers all your questions about SAS Libraries.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 728 views
  • 1 like
  • 2 in conversation