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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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