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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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