jeudi 23 août 2018

SAS: how to check if a column, in an imported excel sheet, contains a string?

I have imported a dataset from a an excel sheet, and I want to delete some observations. Say, I have a variable which tells me if a student has passed or not (with strings "Passed" and "Failed"). I want to delete all the students which have failed from the dataset.

I do know that usually I would be able to do so with an if statement. However, I don't know how to access the temporary dataset. Do I have to open after importing it, and then check with an if statement?

This is how I have tried:

proc import datafile="C:\Users\User\Desktop\testresults.xlsx"

DBMS=XLSX; 

if Status = "failed" then delete

run;

I know this won't work as the "if" condition only works when the data resides in PDV.

Is it possible to delete after importing instead of while importing?

Aucun commentaire:

Enregistrer un commentaire