BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5

/*example1*/

data ex1;

set sashelp.class ;

run;

Note: (exmaple1) In above step backend PDV concept will be executed.

 

/*example2*/

data _null_;

set sashelp.class;

put _all_;

run;

 

my question is like in above step (example2) is backend PDV concept will be applied .
i think not applied . Could you please guide me?

 

 

5 REPLIES 5
andreas_lds
Jade | Level 19

Why do you think that the pdv-concept is not applied in a data _null_ step?

thanikondharish
Calcite | Level 5
No.of iterations won't be formed in new dataset (just an idea)

Can you guide exact point?
Quentin
Super User

As Chris wrote, the PDV is a logical component of the DATA step itself.  If you are writing a DATA step, it has a PDV.

 

In your  sample code code when you use the PUT statement, you are writing values from the PDV to the log.  I added a BY statement for fun, and here is the log:

 

1    data _null_ ;
2      set sashelp.class ;
3      by name ;
4      put _all_;
5    run ;

Name=Alfred Sex=M Age=14 Height=69 Weight=112.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=1
Name=Alice Sex=F Age=13 Height=56.5 Weight=84 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=2
Name=Barbara Sex=F Age=13 Height=65.3 Weight=98 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=3
Name=Carol Sex=F Age=14 Height=62.8 Weight=102.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=4
Name=Henry Sex=M Age=14 Height=63.5 Weight=102.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=5
Name=James Sex=M Age=12 Height=57.3 Weight=83 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=6
Name=Jane Sex=F Age=12 Height=59.8 Weight=84.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=7
Name=Janet Sex=F Age=15 Height=62.5 Weight=112.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=8
Name=Jeffrey Sex=M Age=13 Height=62.5 Weight=84 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=9
Name=John Sex=M Age=12 Height=59 Weight=99.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=10
Name=Joyce Sex=F Age=11 Height=51.3 Weight=50.5 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=11
Name=Judy Sex=F Age=14 Height=64.3 Weight=90 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=12
Name=Louise Sex=F Age=12 Height=56.3 Weight=77 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=13
Name=Mary Sex=F Age=15 Height=66.5 Weight=112 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=14
Name=Philip Sex=M Age=16 Height=72 Weight=150 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=15
Name=Robert Sex=M Age=12 Height=64.8 Weight=128 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=16
Name=Ronald Sex=M Age=15 Height=67 Weight=133 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=17
Name=Thomas Sex=M Age=11 Height=57.5 Weight=85 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=18
Name=William Sex=M Age=15 Height=66.5 Weight=112 FIRST.Name=1 LAST.Name=1 _ERROR_=0 _N_=19
NOTE: There were 19 observations read from the data set SASHELP.CLASS.

You can see there are 9 variables in the PDV.  Five are read from sashelp.class.  Four are automatic variables created by SAS.

 

The data step works by creating the PDV, reading values into the PDV, changing values in the PDV, then writing values from the PDV.  There is always a PDV.

 

As can be seen above, the counter of DATA step iterations, _N_, is always present in the PDV.  The automatic variables _N_ _ERROR_ FIRST.Name LAST.Name are not written to an output dataset, but they exist in the PDV.

 

+1 For Chris's recommendation to play around with the DATA step debugger.  Learning about the PDV is critical to understanding the DATA step, which is critical to understanding SAS.

 

 

The Boston Area SAS Users Group is hosting free webinars!
Next webinar will be in January 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.
mkeintz
PROC Star

The PDV is constructed by the SAS compiler - in advance of actual data processing.   Before any data processing occurs, the compiler makes provision for each variable encountered in a SET, MERGE, INPUT and other data-retrieval statements as well as assignment statements that will calculate values for new variables.

 

And remember, a DATA _NULL_ step does process data, so it would need the PDV to keep variables organized during that process.  

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
ChrisHemedinger
Community Manager

The PDV (program data vector) is present/used in DATA step even when you aren't writing an output data set. To see it in action and get more insight into how it works, use the DATA step debugger (tutorial here). It's a great learning tool.

Register for SAS Innovate 2025!! The premier event for SAS users, May 6-9 in Orlando FL. Sign up now for the best deals!

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 892 views
  • 1 like
  • 5 in conversation