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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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