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

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.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Seems too simple?  Add the clause

WHERE ABS(zcta) < 10000

to your query.

PG

PG

View solution in original post

8 REPLIES 8
PGStats
Opal | Level 21

Seems too simple?  Add the clause

WHERE ABS(zcta) < 10000

to your query.

PG

PG
frank1947
Calcite | Level 5

that was so logical, writing 10k 🙂     --- Thanks

frank1947
Calcite | Level 5

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.

DBailey
Lapis Lazuli | Level 10

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

PGStats
Opal | Level 21

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

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

PG

PG
frank1947
Calcite | Level 5

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

Thanks

DBailey
Lapis Lazuli | Level 10

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;

frank1947
Calcite | Level 5

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

appreciate it!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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