BookmarkSubscribeRSS Feed
aditya1
Calcite | Level 5

Hi i want to create observation GENDER in a row above characteristic how do i do that.

thanks in advance


234.PNG
4 REPLIES 4
ballardw
Super User
data want;
   input characteristic $ ;
datalines;
F
M
;
run;

Is this in an existing data set or are you creating set from scratch?

 

 

If the later then

Kurt_Bremser
Super User

Since "characteristic" seems to be a variable (column) name, you can't add a row "above" it.

To clarify, post your example data in a data step, or use a sashelp dataset to illustrate your issue.

Reeza
Super User

You have a dataset so what are you trying to do?

Customize a report layout is my guess and there are probably better ways to do this - a label for the variable is one way to start off.

art297
Opal | Level 21

Do you want to insert a row or simply rename the variable? If it's the latter, then (assuming you dataset is called have), when opening the dataset simply use something like:

 

set have (rename=(characteristic=gender);

 

Otherwise, if you really want to insert a row, you may first have to use a length statement (before the set statement) and then include code (after the set statement):

data want;
  length characteristic $6;
  set have;
  if characteristic='F' then do;
    hold=characteristic;
    characteristic='Gender';
    output;
    characteristic=hold;
    output;
  end;
  else output;
run;

Art, CEO, AnalystFinder.com

 

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!

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