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...
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.