Help using Base SAS procedures

subsetting observations with a specific ID

Accepted Solution Solved
Reply
Contributor
Posts: 44
Accepted Solution

subsetting observations with a specific ID

data cig.subset;

   set cig.goodpanel;

   by household_id;

   if household_id=='2002189' then output;

quit;

I am new to SAS, and I'm not sure if the fourth line is done correctly. I tried '=' and '==' and the number without '' and with ''.

Nothing worked. Can someone please help?

Many thanks,

C


Accepted Solutions
Solution
‎08-18-2011 05:23 PM
Contributor
Posts: 72

subsetting observations with a specific ID

Instead of using "quit;"  - use a "run;"

View solution in original post


All Replies
PROC Star
Posts: 7,363

subsetting observations with a specific ID

First you have to know whether houshold_id is numeric or character.  Did your log give you an indication of what kind of error you had?

You can discover what type of field it is by running:

proc contents data=cig.goodpanel;

run;

if it is numeric then, in your code, use:

if household_id eq 2002189 then output;

although = would have worked just as well.

if it is character then it may just include extra spaces and you could try

if strip(household_id) eq "2002189" then output;

Let the forum know if that worked and, if not, post your log the next time.

Contributor
Posts: 44

subsetting observations with a specific ID

180

ERROR 180-322: Statement is not valid or it is used out of proper order.

I used the following:

data cig.test;

   set cig.goodpanel;

   by household_id;

   if household_id eq 2002189 then output;

quit;

Solution
‎08-18-2011 05:23 PM
Contributor
Posts: 72

subsetting observations with a specific ID

Instead of using "quit;"  - use a "run;"

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 114 views
  • 3 likes
  • 3 in conversation