BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
wlierman
Lapis Lazuli | Level 10

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

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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;

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

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;
wlierman
Lapis Lazuli | Level 10

Tom

 

The SAS do/end block was just what I needed.

Thank you.

 

wlierman

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 286 views
  • 1 like
  • 2 in conversation