Missed asking this question here
Very similar question, but put quotes for Horsepower > 250 and NOT put quotes for Horsepower if it does not meet the condition.
data _null_;
file "/path/output/unix/cars.csv"
dsd dlm = ',';
set sashelp.cars;
if _n_ = 1 then put @1
"Make,Model,Type,Origin,DriveTrain,MSRP,Invoice,EngineSize,Cylinders,Horsepower,MPG_City,MPG_Highway,Weight,Wheelbase,Length";
put Make
Model
Type
Origin
DriveTrain
MSRP
Invoice
EngineSize
Cylinders
Horsepower ~
MPG_City
MPG_Highway
Weight
Wheelbase
Length;
run;
458 data _null_; 459 set sashelp.cars(obs=5); 460 file log dsd ; 461 put 462 Make 463 Model 464 MSRP 465 EngineSize 466 Cylinders 467 @ 468 ; 469 if horsepower > 250 then put Horsepower ~ @; 470 else put Horsepower @; 471 put 472 MPG_City 473 ; 474 run; Acura,MDX,"$36,945",3.5,6,"265",17 Acura,RSX Type S 2dr,"$23,820",2,4,200,24 Acura,TSX 4dr,"$26,990",2.4,4,200,22 Acura,TL 4dr,"$33,195",3.2,6,"270",20 Acura,3.5 RL 4dr,"$43,755",3.5,6,225,18 NOTE: There were 5 observations read from the data set SASHELP.CARS.
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.