Help using Base SAS procedures

Read Access Varible into SAS

Reply
Occasional Contributor
Posts: 17

Read Access Varible into SAS

I am trying to read two variables from my access database and then do SQL.  But there are three variable in my database: personID, country and city. I only need to read two variables personID and city. How SAS only read the first and third column?

data PersonDS3 ;

Infile Person3 missover firstobs=2;

Input PersonID  City & $25. ;

Proc SQL;

Create table Most_PersonID AS

  SELECT city Count(PersonID)AS CountOfPersonID

  FROM PersonDS3

    GROUP BY city;

quit;

Proc sort data=Most_PersonID; by Descending CountOfPersonID;

Super User
Posts: 17,724

Re: Read Access Varible into SAS

Why are you using infile to read from an Access DB?

I would assume you're using ODBC or some other method that would allow you to DROP the variable on the set statement.

data personD3;

set accessDB (drop=unwanted_var);

run;

Occasional Contributor
Posts: 17

Re: Read Access Varible into SAS

thie is what my database looks like

1.PNG

Occasional Contributor
Posts: 17

Re: Read Access Varible into SAS

And I only want to read PersonID, country and city. But in the city column there are always some gender information. I don't know how to deal with these junk values.22.PNG

Occasional Contributor
Posts: 17

Re: Read Access Varible into SAS

my friend said I should use"if" and "substr" to delete the junk value. but I still couldn't figure it out.

Super User
Posts: 17,724

Re: Read Access Varible into SAS

Were you provided this Access DB in this format or did you receive a text file?

I'd go back a step and fix it there first.

Ask a Question
Discussion stats
  • 5 replies
  • 186 views
  • 0 likes
  • 2 in conversation