Skip to content

Conversation

Kevin-Boone-SAS
Copy link
Contributor

See Data_Step_Select.sas in the By Syntax>DATA Step folder.

Signed-off-by: Kevin Boone kevin.boone@sas.com

Signed-off-by: Kevin-Boone-SAS <kevin.boone@sas.com>
@stever-sas
Copy link
Collaborator

Hi Kevin -

Just curious, what do you think of also adding this code into the sample program so that users can see there is the option to list multiple values in each WHEN clause?

data work.cars_orig_country; /1/
set sashelp.cars(keep=Make Model Origin); /2/
length Origin_Country $25; /3/
select (Make); /4/
when ('Acura', 'Honda', 'Infiniti', 'Isuzu', 'Lexus', 'Mazda', 'Mitsubishi', 'Nissan', 'Scion', 'Subaru', 'Suzuki', 'Toyota')
Origin_Country = 'Japan'; /5/
when ('Hyundai', 'Kia')
Origin_Country = 'South Korea';
when ('Audi', 'BMW', 'Mercedes-Benz', 'Volkswagen', 'Porsche')
Origin_Country = 'Germany';
when ('Jaguar', 'Land Rover', 'MINI')
Origin_Country = 'England';
when ('Saab', 'Volvo')
Origin_Country = 'Sweden';
when ('Buick', 'Cadillac', 'Chevrolet', 'Chrysler', 'Dodge', 'Ford', 'GMC', 'Hummer', 'Jeep', 'Lincoln', 'Mercury', 'Oldsmobile', 'Pontiac', 'Saturn')
Origin_Country = 'United States of America';
otherwise Origin_Country = ''; /6/
end; /7/
rename Origin = Origin_Region; /8/
run;

@Kevin-Boone-SAS
Copy link
Contributor Author

Kevin-Boone-SAS commented Apr 21, 2025 via email

@stever-sas
Copy link
Collaborator

I'm a lazy programmer, so I'm always looking for shortcuts. :) I don't mind making the change. I'll merge the request, then update the program. I'll make a couple of other edits that I'll mention here for future reference:

  • I'll take out EXAMPLE from the program title in the comment and make the program file name and title match.
  • I'll update the doc link to use the default URL that will always point to the latest version of the page.
  • I'll change "CASE statement" to "CASE expression" to be consistent with SQL terminology.
  • I'll change CALCULATED COLUMN to lower case in the keyword list (syntax keywords are in caps, topic keywords are lower) and I'll add 'calculated column' to the kewords.txt file.

@stever-sas stever-sas merged commit 63643b9 into sassoftware:main Apr 21, 2025
1 check passed
@Kevin-Boone-SAS
Copy link
Contributor Author

Kevin-Boone-SAS commented Apr 21, 2025 via email

@stever-sas
Copy link
Collaborator

You did include the 2025.04 link - thank you! I will still change the URL so that it automatically opens the latest version of the page, so next month it will open to 2025.05. If you want to do this yourself in future programs, plug the URL for the doc page into this internal app: https://docportal.unx.sas.com/url-conversion/. Then grab the Production link under Default URLs.

@Kevin-Boone-SAS
Copy link
Contributor Author

Kevin-Boone-SAS commented Apr 21, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants