BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
aarony
Obsidian | Level 7

hi thank u for reading this:

i have variable ticker

ticker

aapl

a

goog.

kld.

aa.

b.

i want to remove the . after goog, kld, aa, and b.

could you help?

thank you!!!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

You can remove all of the periods (even those not at the end of the string) by using the COMPRESS() function.

A= compress(A,'.');

View solution in original post

4 REPLIES 4
Tom
Super User Tom
Super User

You can remove all of the periods (even those not at the end of the string) by using the COMPRESS() function.

A= compress(A,'.');

aarony
Obsidian | Level 7

tom, thank you very much for your kind help.

i have one more question that i believe you have an answer to:

my data looks like this

yr name      strength_a strength_b    strength_c     strength_d class

1991 john            2 1 0 0 a

1991 amy           1 0 2 1 a  

1991 ted             0 2 1 1 b

1991 tom           2 2 0 0 b

1992 john            2 1 0 0 a

1992 amy           1 0 2 1 a  

1992 ted             0 2 1 1 b

1992 tom           2 2 0 0 b

my years are from 1991 to 2012 and i have more observations than the above but i just wanted to give you a picture. my scores range from 0~2.

I want to arrive at the format below:

Yr         name    varname            score    class

1991     john      strength_a 2          a

1991     john      strength_b 1          a

1991     john      strength_c 0          a

1991     john      strength_d 0          a

1991     amy      strength_a 1          a

1991     amy      strength_b 0          a

1991     amy      strength_c 2          a

1991     amy      strength_d 1          a

Could you kindly provde me of your guidance?

Tom
Super User Tom
Super User

That looks like a PROC TRANSPOSE to me.

You will need to sort the data first.

proc transpose data=have out=want prefix=score ;

by yr name class ;

var strength_: ;

run;

aarony
Obsidian | Level 7

tom, this is magic. thank you so much!

what if my data looks like the 1st table below and wanted to arrive at the 2nd table? i tried to apply ur logic but it is not working for some reason. it is spitting out 100s of score: score1, score2,.....  thank you!

yearnameone_str_aone_str_bone_str_cone_con_aone_con_bone_con_ctwo_str_atwo_str_btwo_str_ctwo_con_atwo_con_btwo_con_c
1991john211112111121
1991amy100001000010
1991ted201012101121
1991tom120201020010
1992john010100010000
1992amy022220222202
1992ted211112111121
1992tom122221222212
varnameScore
1991johnone_str_a2
1991johnone_str_b1
1991johnone_str_c1
1991johnone_con_a1
1991johnone_con_b1
1991johnone_con_c2
1991johntwo_str_a1
1991johntwo_str_b1
1991johntwo_str_c1
1991johntwo_con_a1
1991johntwo_con_b2
1991johntwo_con_c1

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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