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

Hi all,

I'm trying to understand the syntax of different codes.

My question is when to use DATAROW, FIRSTOBS=, GETNAMES=NO?

I understand  firstobs displays the obs starting from the particular row no mentioned. Data row is used in the proc import statement to specify from which line to start the data reading and get names = no will skip the description lines written at top of the file. I'm trying to know what else can be the possible things to know apart from those I mentioned. Pretty much all doing the same task.

Or its something more that anyone can please explain .

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

@POOJA_J wrote:

Hi all,

I'm trying to understand the syntax of different codes.

My question is when to use DATAROW, FIRSTOBS=, GETNAMES=NO?

I understand  firstobs displays the obs starting from the particular row no mentioned. Data row is used in the proc import statement to specify from which line to start the data reading and get names = no will skip the description lines written at top of the file. I'm trying to know what else can be the possible things to know apart from those I mentioned. Pretty much all doing the same task.

Or its something more that anyone can please explain .


You seem to mixing from apples and oranges here.  DATAROW= and GETNAMES= are STATEMENTS that can be used as part of PROC IMPORT step.   You can use the GETNAMES= statement to tell PROC IMPORT to treat the first line of the source as names for the variables.  You can use the DATAROW= statement to tell PROC IMPORT on which line it should start reading the data.  Note that one problem with PROC IMPORT is that no matter where you tell it the data starts it still wants to look at the first line for the names if you tell it to get names.

 

There are two places (at least) where you can use FIRSTOBS=.

 

FIRSTOBS= can be a DATASET OPTION that can be used when reading in a dataset.  For example in a SET or MERGE statement.  But also in PROC STATMENT that let's you specify an input dataset.  It says how many observations to skip before start reading the data.  So FIRSTOBS=5 says to skip the first 4 observations and instead start reading at the 5th observation.

 

FIRSTOBS= can also be an option on the INFILE statement that will control how many lines of the input file will be skipped before it starts reading the lines.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

@POOJA_J wrote:

Hi all,

I'm trying to understand the syntax of different codes.

My question is when to use DATAROW, FIRSTOBS=, GETNAMES=NO?

I understand  firstobs displays the obs starting from the particular row no mentioned. Data row is used in the proc import statement to specify from which line to start the data reading and get names = no will skip the description lines written at top of the file. I'm trying to know what else can be the possible things to know apart from those I mentioned. Pretty much all doing the same task.

Or its something more that anyone can please explain .


You seem to mixing from apples and oranges here.  DATAROW= and GETNAMES= are STATEMENTS that can be used as part of PROC IMPORT step.   You can use the GETNAMES= statement to tell PROC IMPORT to treat the first line of the source as names for the variables.  You can use the DATAROW= statement to tell PROC IMPORT on which line it should start reading the data.  Note that one problem with PROC IMPORT is that no matter where you tell it the data starts it still wants to look at the first line for the names if you tell it to get names.

 

There are two places (at least) where you can use FIRSTOBS=.

 

FIRSTOBS= can be a DATASET OPTION that can be used when reading in a dataset.  For example in a SET or MERGE statement.  But also in PROC STATMENT that let's you specify an input dataset.  It says how many observations to skip before start reading the data.  So FIRSTOBS=5 says to skip the first 4 observations and instead start reading at the 5th observation.

 

FIRSTOBS= can also be an option on the INFILE statement that will control how many lines of the input file will be skipped before it starts reading the lines.

POOJA_J
Obsidian | Level 7
Thanks a lot for detailed explanation. I appreciate it.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 267 views
  • 1 like
  • 2 in conversation