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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 8 replies
  • 1034 views
  • 0 likes
  • 4 in conversation