Hello
I am doing export of SASHELP.CARS data set into txt file.
Then I want to import it using infile statement and also I want to control the columns names .
However, as you can see in the result of import there is a problem.
The original columns names are in the data set ..
what is the way to solve it please?
/***export to txt file with column headers*/
proc export data=sashelp.cars
outfile="/path/cars.txt"
dbms=tab
replace;
run;
/*Import*/
data cars;
infile "/path/cars.txt" dlm='09'X dsd truncover;
input Carmake :$50.
Carmodel :$50.
Cartype :$50.
origin :$50.
DriveTrain :$50.
MSRP
InvoiceNumber
EngineSize
NumberCylinders
HP
MPG_In_City
MPG_In_Highway
CarWeight
Wheelbase ;
run;
Okay, I found the solution.
Need to use firstobs=2
data cars;
infile "/path/carstbl1.txt"
firstobs=2
dlm='09'X dsd truncover;
input Carmake :$50.
Carmodel :$50.
Cartype :$50.
origin :$50.
DriveTrain :$50.
MSRP : $8.
InvoiceNumber : $8.
EngineSize
NumberCylinders
HP
MPG_In_City
MPG_In_Highway
CarWeight
Wheelbase ;
run;
Okay, I found the solution.
Need to use firstobs=2
data cars;
infile "/path/carstbl1.txt"
firstobs=2
dlm='09'X dsd truncover;
input Carmake :$50.
Carmodel :$50.
Cartype :$50.
origin :$50.
DriveTrain :$50.
MSRP : $8.
InvoiceNumber : $8.
EngineSize
NumberCylinders
HP
MPG_In_City
MPG_In_Highway
CarWeight
Wheelbase ;
run;
Hey, man
I am having troubles with my dataset. I'm getting a invalid option name INPUT. Help would be appreciated...
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.