DATA Step, Macro, Functions and more

why if won't work in proc step

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

why if won't work in proc step

Hi Team,

 

I would like to know why if won't work in SAS. can any one please explain the same by using PDV concept. 

 

Note: I am not expecting regular/ standard answers like if statement won't work in proc step. 

 

Thanks & Regards,

Bhanuprakash Pala


Accepted Solutions
Solution
‎05-17-2018 01:38 PM
Super User
Posts: 6,939

Re: why if won't work in proc step

Posted in reply to bhanuprakash

IF lets SAS examine current values in the PDV (including values that were calculated along the way, but not part of the incoming data set). 

 

WHERE lets SAS examine the contents of the incoming data, whether or not a PDV exists.  In a DATA step, WHERE screens out observations before they get read into the PDV.

 

PROC steps don't have a PDV, so WHERE is the only choice available.

View solution in original post


All Replies
PROC Star
Posts: 1,472

Re: why if won't work in proc step

Posted in reply to bhanuprakash

Please show an example of code which shows how you are trying to use the IF statement (which PROC?), and describe what you mean by "won't work."  In general, you can look up the syntax for a PROC in the documentation to see what statements are allowed.

 

 

Super User
Posts: 24,028

Re: why if won't work in proc step

Posted in reply to bhanuprakash

@bhanuprakash wrote:

Hi Team,

 

I would like to know why if won't work in SAS. can any one please explain the same by using PDV concept. 

 

Note: I am not expecting regular/ standard answers like if statement won't work in proc step. 

 

Thanks & Regards,

Bhanuprakash Pala


Certain PROCs support standard programming statements and some don't. The ones that do, have it identified in the PROC documentation, in Syntax list, under PROGRAMMING STATEMENTS.

PROC PHREG supports programming statements such as IF

http://documentation.sas.com/?docsetId=statug&docsetTarget=statug_phreg_syntax19.htm&docsetVersion=1...

 

In general, most procedures do not support programming statements. 

A PROC is essentially a customized procedure designed to accomplish a specific task, where as data step with programming statements are generic and you can do a lot of different data manipulations within the data step. 

Frequent Contributor
Posts: 105

Re: why if won't work in proc step

Posted in reply to bhanuprakash

I would request and suggest you to please refer to text books/sas documentation and various technical papers  on this topic, then quote examples with your understanding and elaborate your question with certain references to your examples and understanding to make it precise

Solution
‎05-17-2018 01:38 PM
Super User
Posts: 6,939

Re: why if won't work in proc step

Posted in reply to bhanuprakash

IF lets SAS examine current values in the PDV (including values that were calculated along the way, but not part of the incoming data set). 

 

WHERE lets SAS examine the contents of the incoming data, whether or not a PDV exists.  In a DATA step, WHERE screens out observations before they get read into the PDV.

 

PROC steps don't have a PDV, so WHERE is the only choice available.

Occasional Contributor
Posts: 5

Re: why if won't work in proc step

Posted in reply to Astounding
Hi Astounding,

Thanks for the best reply. I expected the same kind of answer.

As you mentioned in the earlier if proc steps don't have PDV, then how sub setting and renaming are working.

can you please explain how it will work in background.

Thanks & Regards,
Bhanuprakash Pala
Super User
Posts: 13,950

Re: why if won't work in proc step

Posted in reply to bhanuprakash

Many procedures support a separate where statement to subset data.

 

Data set options are always available.

 

This is an example of using the data set option where to subset data to only values of 'F' For the variable Sex and rename the existing variable "Name" to "PersonName".

 

Proc print data = sashelp.class (where= (sex='F')  rename=(name=PersonName) );

run;

 

The where dataset option may have restrictions on uses of functions calculating values.

Super User
Posts: 6,939

Re: why if won't work in proc step

Posted in reply to bhanuprakash

SAS doesn't say a whole lot about the internal workings of the software.  We know that there is additional data movement along the way.  For example, a DATA step doesn't read data directly from a SAS data set into the PDV.  Rather, it moves a block of data into memory, and then reads observations (one at a time) from that block into the PDV.  That's not the real point here ... more to the point is that the real process isn't widely described.

 

In a PROC step as well, there must be additional data movement along the way.  But we don't really know how and where that data movement occurs.  As you have noted, however, SAS does have the ability to subset, drop, and rename at some point.  We just don't know (at least I just don't know) what the intermediate storage locations are and where the renaming takes place.

Occasional Contributor
Posts: 5

Re: why if won't work in proc step

Posted in reply to Astounding
Thanks for the reply.

yes, I too agree most of the points I am not able to figure out how those are working in back end(it might be compilation or execution). so that's why I posed this question. however we don't have a way to learn this.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 172 views
  • 2 likes
  • 6 in conversation