Write and run SAS programs in your web browser

edit a data set

Reply
Occasional Contributor
Posts: 19

edit a data set

is it posible to work with proc fsedit under sas for university. If not, how do i get to modify my data set on line?

Super User
Super User
Posts: 7,702

Re: edit a data set

Even if its possible to use fsedit (and not sure as I don't use it), you will find that typing things into Excel and then importing the file is far easier to get data in - obviously remember Excel is a bad medium for data, however its big selling is that its easy as a data entry system.

Occasional Contributor
Posts: 19

Re: edit a data set

I usually import Excel files but sometimes is more easier to use proc fsedit to correct a sas file
Super User
Posts: 11,114

Re: edit a data set

I would suggest learning to use a more formal approach. Specific details might vary depending on the type of edit needed.

I would start by looking at data step code, possibly with an UPDATE or if the data correction is more rule based then IF/Then or appropriate selection and assignment statements.

 

Rationale: If Ihave the base data and a program to change it I can 1) undo the change if needed; 2) document all of the changes made; and 3) think about the data change while writing the code.

 

For some rough examples, I have worked with a lot of survey data where the questionnaire involved skip patterns (should have a response to this question only if the answer to another was a specific response or range of responses). If I "correct" something that now requires the follow up responses I might end up with a lot of enter, run check code and enter additional fixes, or if I correct something so that previously unanswered questions require a response there is other work.

In a data step i can so something like:

 

Data recoded;

   set raw;

  /* this respondents response to open end indicates that q1 should have been coded 4,

     follow up questions were not answered but are set to no response*/

   if respondent = '123' then do;

       q1=4;

       q1a=99;

        q1b=99;

   end;

run;

 

One advantage to this approach is if I need to make the same series of edits I can change the If statement to
if respondent in ('123', '456', '459', '645') then do;

       

Or image a case where a data collection system had a programming error and all the values to field that were recorded as 7 should actually be 77?

If q27=7 then q27=77;

in a datastep is much easier that opening a data set, finding the values and retyping them.

 

A single data step could have hundreds or thousands of edits that are reproducable as needed.

Occasional Contributor
Posts: 19

Re: edit a data set

I usually use if statement to correct some data, but in some occasions it is very useful, to be able to edit the file.

I will continue to work with the if sentence or export the data set to Excel.

Thanks a lot


Super User
Posts: 19,063

Re: edit a data set


adricano wrote:
I usually use if statement to correct some data, but in some occasions it is very useful, to be able to edit the file.

I will continue to work with the if sentence or export the data set to Excel.

Thanks a lot



It's useful to edit it manually but it's not a best practice by far. These days everything needs to be reproducible, especially if it's scientific research or a work product. In that respect, coding will include all the changes even if your IF/THEN statements are more tedious in the beginning but will save you headaches down the road. 

 

FYI - In a recent interview process that I had, one candidate distinguished themselves by being the only candidate to correctly read in all the data AND documenting the data fixes. It seems small, but this really matters in the long run.

Ask a Question
Discussion stats
  • 5 replies
  • 167 views
  • 1 like
  • 4 in conversation