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.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

5 Steps to Your First Analytics Project Using SAS

For SAS newbies, this video is a great way to get started. James Harroun walks through the process using SAS Studio for SAS OnDemand for Academics, but the same steps apply to any analytics project.

Find more tutorials on the SAS Users YouTube channel.

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