BookmarkSubscribeRSS Feed
mikepark
Obsidian | Level 7

I memorized a lot of the top SAS functions. However, what is the computer thinking or doing when it is executing a function in the data step?  I have a taught myself a lot in the last few months. However, I don't have a strong enough grasp of the PDV and what the computer is exactly doing. Any suggested resources to help me understand better?

6 REPLIES 6
ChrisNZ
Tourmaline | Level 20

A big difference is whether a function is called in an IF or a WHERE statement.

 

WHERE statements are applied before the PDV is loaded, so the functions can't access the variables from the PDV and are often much slower than the same functions used in an IF statement.

 

 

 

mikepark
Obsidian | Level 7

What is this is the code I am running?

 

data mixed;
set learn.mixed;
Name = upcase(Name);
run;

 

The observation is read into the PDV and then the upcase function is applied to an observation. This is before it moves the next observation that is read in and then the function is applied to it?

ChrisNZ
Tourmaline | Level 20

1. The SET statement loads the data from LEARN.MIXED into the PDV

2. The upcase function update the value of a variable in the PDV.

3. The run statement triggers an (implicit) output in the MIXED table.

4. The iterator go to the top of the data step. Executes 1. again if more observations are available.

 

ScottBass
Rhodochrosite | Level 12

Do what many SAS programmers have never done...read this:

 

https://documentation.sas.com/api/docsets/lrcon/9.4/content/lrcon.pdf

 

When I was first learning SAS a billion years ago, this was about 120 pages.  How times have changed.

 

It's (now) a big doc - skip the parts you don't need right now (eg. Part 3 if you don't have CAS).

 

But if you do invest the time to read this over a couple weekends it will serve you well.

 

Start with Chapter 20 if you want a head start, but I recommend you read most of this document.


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
Patrick
Opal | Level 21

@mikepark 

I agree with @ScottBass  Reading the Concepts is seriously worth it. You don't need to understand everything that's in it as a beginner. Just make it a habit to browse through this documentation from time to time as you'll pick-up more and more as you progress and even more importantly you start to understand where you can tweak your coding approaches to better align them with how SAS works.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 844 views
  • 5 likes
  • 5 in conversation