Desktop productivity for business analysts and programmers

proc sql query help plz

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

proc sql query help plz

Hi all, i have one variable, 'zcta'. it has 5 digit value and 4 digit value but i want to pull up information where 'zcta' has only 4 digit. How can i do that?  ---Thanks.


Accepted Solutions
Solution
‎03-27-2013 01:55 PM
Respected Advisor
Posts: 4,801

Re: proc sql query help plz

Seems too simple?  Add the clause

WHERE ABS(zcta) < 10000

to your query.

PG

PG

View solution in original post


All Replies
Solution
‎03-27-2013 01:55 PM
Respected Advisor
Posts: 4,801

Re: proc sql query help plz

Seems too simple?  Add the clause

WHERE ABS(zcta) < 10000

to your query.

PG

PG
Occasional Contributor
Posts: 9

Re: proc sql query help plz

that was so logical, writing 10k :-)     --- Thanks

Occasional Contributor
Posts: 9

Re: proc sql query help plz

Hi PGSTATS, can i get hint on this-if you can please?

i have two variable in dataset named 'telno' and 'state', couple of state required zero '0' in front of 'telno' variable. if i wants to add zero '0' for couple of states only, how can i do that? 'telno' is a numeric variable...

Thanks.

Super Contributor
Posts: 578

Re: proc sql query help plz

case when state in ('s1','s2','s3') then '0' end || telno as telno2

Respected Advisor
Posts: 4,801

Re: proc sql query help plz

telno is numeric, cannot be a || operand. Rather :

cats(case when state in ('s1','s2','s3') then '0' end, telno) as telnoChr

PG

PG
Occasional Contributor
Posts: 9

Re: proc sql query help plz

@ DBailey- can you please write proc sql step with it - i don't know but i am not just getting it right...

Thanks

Super Contributor
Posts: 578

Re: proc sql query help plz

proc sql;

create table want as

select

     state,

     telno,

     cats(case when state in ('s1','s2','s3') then '0' end, telno) as telnoChr

from

     have;

quit;

Occasional Contributor
Posts: 9

Re: proc sql query help plz

Thanks you so much DBailey and PGStats. It worked...

appreciate it!

🔒 This topic is solved and locked.

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

Discussion stats
  • 8 replies
  • 318 views
  • 7 likes
  • 3 in conversation