DATA Step, Macro, Functions and more

Question about reading data

Reply
New User
Posts: 1

Question about reading data

[ Edited ]

below is my raw data and i am trying to improt it in SAS environment but first line is missing also last varaible value also missing, Please help to reflect all value in all Variable and Observation.

 

Store Revenue Staff Salary Operation Profit Complaint Turnover
STORE101 128000 18 29200 15200 83600 5 2
STORE102 158000 17 19000 12000 127000 11 2
STORE103 138000 18 26300 10500 101200 7 1
STORE104 101000 17 19700 19700 61600 5 2
STORE105 123000 15 29500 10400 83100 7 1
STORE106 189000 13 24400 12600 152000 5 2
STORE107 135000 10 24800 11900 98300 5 2
STORE108 130000 14 19400 11000 99600 3 1
STORE109 191000 12 28300 10500 152200 8 2
STORE110 176000 10 23500 15900 136600 9 1

 

my coding was I pulled this data from extenal file which name is SAS Data.

 

data SAM.vikas;
infile '/folders/myshortcuts/MyFolders/SAS Data.txt';
input Store$ Revenue Staff Salary Operation Profit Complaint Turnover;
run;

Super User
Super User
Posts: 7,860

Re: Question about reading data

You need to tell it to skip over the header line. That is most likely why the first observation is all missing. You can use the FIRSTOBS= option on the INFILE statement.

Your file probably was made on a PC and so is using CR+LF as the end of line characters instead of LF like Unix uses. That is probably what is causing the last variable to not be read as the CR character is making the value an invalid numer.

You also migth want to define STORE as longer than the default 8 characters. 8 should be enough for the values you have posted, but if later in the file there are longer values they will be truncated.

Try this.

data SAM.vikas;
  infile '/folders/myshortcuts/MyFolders/SAS Data.txt'
    firstobs=2 termstr=CRLF truncover
  ;
  length store $12 ;
  input Store Revenue Staff Salary Operation Profit Complaint Turnover;
run;
Ask a Question
Discussion stats
  • 1 reply
  • 150 views
  • 0 likes
  • 2 in conversation