BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,
I have one dataset (data1) with single observation say: something|to|be|written|here.

I have to create other dataset(data2) from above dataset(data1) with below observations:
something
to
be
written
here

I have to do this using scan function only.

Please Help!!!


Thanks,
Hema Tandon
3 REPLIES 3
Patrick
Opal | Level 21
Hema

You only learn it by solving it yourself - or at least invest some time trying to find out.
You'll find everything in the Online Doc and there are normally also examples.

But let's assume you waited too long before starting with work....

data have;
var="something|to|be|written|here.";
run;
data want;
set have;
length newvar $ 10;
keep newvar;
do i=1 to length(var) while(scan(var,i,'|') ne '' );
newvar=scan(var,i,'|');
output;
end;
run;
proc print data=want;
run;
deleted_user
Not applicable
Thanks Patrick,

I was missing output statement in the code I wrote 😞

I am new to SAS,trying to practice it but not able to find much exercises for trying writing new codes.

Regards,
Hema Tandon
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggested Internet search:

sas programming exercises


Also, you will find code samples here:

http://support.sas.com/documentation/onlinedoc/code.samples.html


Scott Barry
SBBWorks, Inc.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 3 replies
  • 1277 views
  • 0 likes
  • 3 in conversation