DATA Step, Macro, Functions and more

Is there a way to add an extra variable column while importing a data?

Accepted Solution Solved
Reply
Contributor
Posts: 23
Accepted Solution

Is there a way to add an extra variable column while importing a data?

Hi
 
I have a dataset of 5 variables  (Name,Age,Gender,Recepie and status).
I want to add a new variable(country) which will have "India" as a value thru out all the rows.
 
Name   Age     Gender   Recepie     status                 Country
vinu      56         F           Tandoor     complete             Canada
 
please reply.

Accepted Solutions
Solution
‎12-14-2016 08:13 AM
Trusted Advisor
Posts: 1,128

Re: Is there a way to add an extra variable column while importing a data?

Try

data want;
set have;
retain country 'Canada';
run;

Thanks,
Jag

View solution in original post


All Replies
Contributor
Posts: 23

Re: Is there a way to add an extra variable column while importing a data?

Hi please ignore the previous message.
 
I have a dataset of 5 variables  (Name,Age,Gender,Recepie and status).
I want to add a new variable(country) which will have "Canada" as a value thru out all the rows.
 
Name   Age     Gender   Recepie     status                 Country
vinu      56         F           Tandoor     complete             Canada
Solution
‎12-14-2016 08:13 AM
Trusted Advisor
Posts: 1,128

Re: Is there a way to add an extra variable column while importing a data?

Try

data want;
set have;
retain country 'Canada';
run;

Thanks,
Jag
Super User
Posts: 10,500

Re: Is there a way to add an extra variable column while importing a data?

As a generic comment: any data imported using a data step can do practically anything you want in a data step. I routinely in a read data step add analysis and data quality indicator variables, write messages to the log or another file about suspect values or data inconsistencies, recode character values to numeric and/or apply standardization rules such as proper case or sentence case to character variables.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 166 views
  • 0 likes
  • 3 in conversation