BookmarkSubscribeRSS Feed
R_Win
Calcite | Level 5
i have a data set
data i;
input x;
cards;
7
8
9
10
11
run;

now i want a new variable to be addeed the variable name should be employ and the observations should be employee1,employee2,employee3,employee4,employee5.
2 REPLIES 2
andreas_lds
Jade | Level 19
It is not necessary to open a second thread for the same topic.
http://support.sas.com/forums/thread.jspa?threadID=3901&tstart=15

Does the number in "employee1" depend on
a) the number of the current obersavtion,
b) any other variable in that oberservation?

One possible solution:
[pre]
data work.extended;
set i;
length employ $ 15; /* defines a character-variable, with enough space for 15 chars */
employ = cat('employee', _n_); /* _n_ = the number of the current obersvation */
run;
[/pre]
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Share info about what you would like the end result to look like - multiple observations and variables, multiple variables and one observation. Do you want the "employ" order to be sorted, based on some component of a SAS variable or just based on the raw input occurrences?

Consider using PROC TRANSPOSE if you want to have one observation in total and a unique SAS variable employee1 through employee## for each unique value.

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

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1060 views
  • 0 likes
  • 3 in conversation