BookmarkSubscribeRSS Feed
david27
Quartz | Level 8

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;
1 REPLY 1
Tom
Super User Tom
Super User
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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 308 views
  • 3 likes
  • 2 in conversation