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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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