BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

Please show what you want as I have no idea at this point what the goal of this process is.

If you want to change the name of COL1 to FRED then RENAME is the way to go.

Why would it work any differently than what you did for numeric variables?

 

Mscarboncopy
Pyrite | Level 9

For the numeric I was using Scan to create the name but for the character I had to use rename, as you suggested. Thank you so much for your (and everyone's) help. I know there were a lot of messages back and forth but they really help me see what I am doing incorrectly. It is extremely helpful to have someone with extensive knowledge to look through the issues and suggest different ways to work with them. I learn a lot this way. I use these topics a lot in this board and I usually find the answers I need, which is great. When I don't and I post mine, all of you are amazing!  It is an amazing learning process you can't get anywhere else.

Mscarboncopy
Pyrite | Level 9

It does not look like I need the suffix. I will only use the rename option ! Thank you so much. It is much appreciated. 

Mscarboncopy
Pyrite | Level 9

To update how I ended up solving this, after everyone's help. Thank you all again. 

I used

proc transpose
  data=have
  out=long (
    where=(col1 ne 0)
  )
;
by obs;
var med:;
run;

data want;
set long;
med = scan(_name_,-1,"_");
drop _name_ col1;
run;

 and replaced  col1 ne 0 with col1 ne  ' ' for the character variables and use RENAME col 1 in the data step for character variables instead of scan. 

Data want2 (rename=(col1=mycharactervarname));

set long;

Run;

I transposed each variable separately and then merged them all. I have not done the date variables yet, but it should be straightforward. I used col2 to check for duplicates in my data file (before dropping it) and found out which ones they were and removed them from my have  file (as when this happens, it indicates a data collection mistake in this case). I hope this can help others as well.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 33 replies
  • 1822 views
  • 3 likes
  • 5 in conversation