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

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

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

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

8 REPLIES 8
Quentin
Super User

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.

 

 

BASUG is hosting free webinars Next up: Jane Eslinger presenting PROC REPORT and the ODS EXCEL destination on Mar 27 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
Reeza
Super User

@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. 

MarkWik
Quartz | Level 8

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

Astounding
PROC Star

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.

bhanuprakash
Obsidian | Level 7
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
ballardw
Super User

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.

Astounding
PROC Star

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.

bhanuprakash
Obsidian | Level 7
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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 8 replies
  • 1489 views
  • 2 likes
  • 6 in conversation