BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
robertrao
Quartz | Level 8


Hi,

I was trying to use a cntlin format and need some help with correct usage of the where statement in this case

data want;

set have;

where put(ID,format1)="yes" and put(Number,format2)="yes"

run;

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

This looks perfect, as long as ID and NUMBER are both numeric variables.

View solution in original post

6 REPLIES 6
ballardw
Super User

The put bits need a period at the end of the format, ie FORMAT1. and FORMAT2. as a minimum. Don't forget the ; at the end of the statement.

Also the case of the formatted value will need to match exactly.

If format1 was defined to create 'Yes' then that is the value you need to use for comparison.

CNTLIN data set is normally used by PROC Format. Were you trying to modify it before sending to Proc Format?

Astounding
PROC Star

Also note ...

If ID is a character variable then the first PUT function must use a character format (format name beginning with $).

robertrao
Quartz | Level 8

I am sorry for that syntax errors..

If both the conditions are met then only I want to pull those records from HAVE dataset.

CNTLIN formats were written for the ID and Number variables already

data want;

set have;

where put(ID,format1.)="yes" and put(Number,format2.)="yes";

run;

Thanks

Astounding
PROC Star

This looks better, except in one regard.  It's hard to believe that CNTLIN accepted format names of "format1" and "format2".  You are not allowed to create format names that end with a number.  If you used different names, show the actual code.  If you actually used "format1" and "format2" you should change them in the CNTLIN data set or else you will get zero observations selected.


robertrao
Quartz | Level 8

hi,

Thanks for the reply. I corrected it. Is this below code fine to use?????and bringing records which  satisfies both the conditions?????

where put(ID,serial.)="yes" and put(Number,numb.)="yes";

Thanks

Astounding
PROC Star

This looks perfect, as long as ID and NUMBER are both numeric variables.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 1092 views
  • 6 likes
  • 3 in conversation