I am trying to clean up some fields in a data set that I constructed from an excel spreadsheet. The part of the SAS data set that I am working with looks like:
Age NAICS_Sector Sector_Type Type_Firm Other_Categories
17 Services Education Education_HS
10 Services Education Education_Elementary
20 Services Education Education_Comm_Coll
and so on.
What I would like is the following:
Age NAICS_Sector Sector_Type Type_Firm Other_Categories
17 Student
10 Student
20 Student
I want to keep students who were (most) likely not working during covid lock-down
Data SAS_Empl.Arias_POE_Final_A;
Set SAS_Empl.Arias_POE_FINAL;
If 6 <= Age <= 22 and Type_Firm = "Education_Services_Student"
then Other_Categories = "STUDENT";
run;
separate from employed persons working in the Services and Goods industries during the lock-down.
My idea was to code as shown in the code box (that is just one example line). But what I would also like for each obs that satisfies the code was to delete whatever values are in the other fields:
NAICS_Sector Sector_Type and Type_Firm
I can't figure out how to do that all (correctly write the value in the Other_Categories field while deleting whatever is in the other fields in one pass for each obs.
Thank you for your help as always.
Wlierman
I think you are look for DO / END block so you can execute multiple statement when the condition is met.
So you probably want a pattern like this:
if (some boolean expression) then do;
other_categories='Student';
call missing(of NAICS_Sector Sector_Type Type_Firm );
end;
I think you are look for DO / END block so you can execute multiple statement when the condition is met.
So you probably want a pattern like this:
if (some boolean expression) then do;
other_categories='Student';
call missing(of NAICS_Sector Sector_Type Type_Firm );
end;
Tom
The SAS do/end block was just what I needed.
Thank you.
wlierman
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.