BookmarkSubscribeRSS Feed
BrahmanandaRao
Lapis Lazuli | Level 10

Hi Guys 

Below dataset split into three datasets like alphabet , digits ,special characters

using compress function  i do not know exactly scan function can do this  scenario 

data special_char;
x='abacd123=@7!*#$ ^';
run;
8 REPLIES 8
Tom
Super User Tom
Super User

Is there an actual question here?
What is it that you want to do with that dataset?

BrahmanandaRao
Lapis Lazuli | Level 10

split into three datasets 

alphabet digits special characters 

mkeintz
PROC Star

You want three datasets?  Not three variables (one for each class of character)?

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Kurt_Bremser
Super User

It seems we even have to write your questions for you.

Do you mean to have three datasets, each with a character variable x,

where the first contains

abacd

the second

123

and the third

=@7!*#$ ^

?

BrahmanandaRao
Lapis Lazuli | Level 10
Yes i want create datasets individually as you said

data char digit special;
x='abacd123=@7!*#$ ^';
char=compress(x,,'ak');
digit=compress(x,,'kd');
specialchar=compress(x,,'kp');
run;
i do not know how to keep special characters using compress function
Kurt_Bremser
Super User

You already have everything you need, you just need to use it "the other way round".

So ask yourself first: "what does the modifier string 'ak' do?"

Tom
Super User Tom
Super User

But that code just creates three duplicates of the same dataset.

 

If 'ka' keeps alpha and 'kd' keeps digits then to get everything else use 'ad' without the k.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 1222 views
  • 0 likes
  • 4 in conversation