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-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!

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