DATA Step, Macro, Functions and more

0 observations and 18 variables

Reply
New Contributor
Posts: 4

0 observations and 18 variables

I run the program it come out this:

 

NOTE: The data set WORK.DST1 has 0 observations and 18 variables. what does it mean ? Does it mean ? My data is in csv file .

Super Contributor
Posts: 340

Re: 0 observations and 18 variables

Hi,

 

Observations in SAS are like rows or records of data. The message you are seeing indicates that the SAS data set (table) you have created holds no rows / records.

 

Share your code and a representative sample of the input data that can be read by your code. Also share the log.

 

 

Regards,

Amir.

New Contributor
Posts: 4

Re: 0 observations and 18 variables

Hi Amir,

  Thank you for helping me. Sample of data like that:
 
 please see the attached file.

;

Thanks .
 
also, how should  I import data like this. it is a csv file. Thanks.
Super Contributor
Posts: 340

Re: 0 observations and 18 variables

You have to describe more precisely your needs.

 

Here are the contents of your csv file :

 

Trial - 2015,,,,,
,,,,,
food  quality data,,,,,
,,,,,
Plot,Cultigen number,Rep,Loc,Std,1
,,,,,
6360,1,1,CIe,6,11
,,,,,
6366,2,1,CIe,6,.

What should the output dataset look like ? What are the names/formats of the columns ?

Frequent Contributor
Posts: 77

Re: 0 observations and 18 variables

[ Edited ]
data FoodQualityData;
infile "path/filename.csv" firstobs = 6 dsd;
input Plot Cultigen number Rep Loc $ Std _1;
run;
New Contributor
Posts: 4

Re: 0 observations and 18 variables

Posted in reply to MadhuKorni
HI , I try your code , but it is only read the first line of data which is
empty.

here is the note form the lot:




NOTE: The infile "C:\Users\Guo\Desktop\trail 2015.csv" is:
Filename=C:\Users\Guo\Desktop\trail 2015.csv,
RECFM=V,LRECL=32767,File Size (bytes)=145,
Last Modified=18Jun2018:13:56:50,
Create Time=18Jun2018:13:56:49

NOTE: Invalid data for Plot in line 2 1-5.
NOTE: Invalid data for Cultigennumber in line 3 1-20.
NOTE: Invalid data for Rep in line 4 1-5.
NOTE: Invalid data for Loc in line 5 1-8.
NOTE: Invalid data for Std in line 5 9-16.
NOTE: Invalid data for _1 in line 5 17-24.
RULE:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+---
1 Trial - 2015,,,,, 17
2 ,,,,, 5
3 food quality data,,,,, 23
4 ,,,,, 5
5 Plot,Cultigen number,Rep,Loc,Std,1 34
Plot=. Cultigennumber=. Rep=. Loc=. Std=. _1=. _ERROR_=1 _N_=1
NOTE: 6 records were read from the infile "C:\Users\Guo\Desktop\\trail
2015.csv".
The minimum record length was 5.
The maximum record length was 34.
NOTE: SAS went to a new line when INPUT statement reached past the end of a
line.
NOTE: The data set WORK.FOODQUALITYDATA has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
real time 0.34 seconds
cpu time 0.32 seconds

The output is like this :


SAS Output
The SAS System
Obs Plot Cultigennumber Rep Loc Std _1
1 . . . . . .

do you know why? hoe can I fix it thanks.


Frequent Contributor
Posts: 77

Re: 0 observations and 18 variables

data FoodQualityData;
infile "path/filename.csv" firstobs = 6 dsd;
input Plot Cultigen number Rep Loc $ Std _1;
run;

open your file and check from which line the data starts and mention it in firstobs option.
I found only 7 variables in the files. So, I mentioned only 7 variables in the input statement. Ex : if the data starts from 6th line mention firstobs = 6 if it starts from 10th line then firstobs = 10
New Contributor
Posts: 4

Re: 0 observations and 18 variables

The code:

 

COMMENT READ QUALITY DATA;

   DATA DST1;

      INPUT PLOT CLe /*more , input 18 Variable*/;

      DATALINES;

Super Contributor
Posts: 340

Re: 0 observations and 18 variables

Hi,

 

If your data is in a separate csv file then there should be no need to use datalines as shown in your code. The data step you have shown is incomplete. Please copy and pate the log, showing the SAS code and any messages after it is executed.

 

You can use the infile statement to specify the csv file and path:

 

http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=n1rill4udj0tfun1fvce3j401plo.htm&docs...

 

A simple example template is:

 

data dst1;
   infile '<your-path-and-file-name.csv>' dsd;
   input <your-variable-names-and-formats>;
run;

 

I cannot download your file, but from what @gamotte has shown it does not appear to have a clear structure which is why it would be helpful to also see the output you expect to see, based on the file you've provided, also as @gamotte has advised. You might need some extra logic in your data step to help you read in the csv file.

 

 

Regards,

Amir.

Super Contributor
Posts: 340

Re: 0 observations and 18 variables

Which program ?

 

The log message says that SAS has created a dataset DST1 in the work library. This dataset has 18 columns but no row of data, i.e. it's an empty dataset.

 

Can you show the code and describe expected output.

Ask a Question
Discussion stats
  • 9 replies
  • 125 views
  • 0 likes
  • 4 in conversation