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

 

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
  • 2 replies
  • 927 views
  • 1 like
  • 2 in conversation