BookmarkSubscribeRSS Feed
VIWA
Calcite | Level 5

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;

1 REPLY 1
Tom
Super User Tom
Super User

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;

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
  • 1 reply
  • 670 views
  • 0 likes
  • 2 in conversation