DATA Step, Macro, Functions and more

Add a column to sas file

Accepted Solution Solved
Reply
Contributor
Posts: 70
Accepted Solution

Add a column to sas file

Hello

 

I have SAV file that includes 124 columns and 4000 lines.

 

I do not know why I can not import an excel file to SAS (working via the university), so now I am trying to do other action in order to add data.

 

I want to add an additional column (new variable) with 4000 lines to the existing SAV file. How do you suggest to do it (I check in this community and find many options like SQL but I am not sure about it).

 

Thanks for any clue

 

Hedva


Accepted Solutions
Solution
‎03-14-2018 07:09 AM
Super User
Posts: 22,820

Re: Add a column to sas file

SAS UE can deal with Excel files and SPSS files without issues. 

 

How are you importing your data? If you're not sure of the code and such and are more familiar with SPSS point and click interface, I recommend using the GUI tasks instead of trying to code. 

 

 

View solution in original post


All Replies
Super User
Super User
Posts: 9,193

Re: Add a column to sas file

What is a SAV file?

 

"I do not know why I can not import an excel file to SAS (working via the university)" - we don't know either, perhaps if you told us what you were doing, what errors you get etc.  As UE runs on a virtual linux image which Office is not, then yes SAS cannot process Excel files.  You can of course save the Excel file as CSV and then import that into SAS (the problem here lies with Office which is proprietary Windows only software).  

 

As for adding another column, you can do this in any number of ways through datastep (this is the main language) or sql sub component.  For example here I add a column to the dataset have outputting to a new dataset want:

data want;
  set have;
  new_var=1 + 2;
run;

new_var will default to numeric length 8 as I did not specify any format or type.  You need to provide more information on your specifics for us to help.

Solution
‎03-14-2018 07:09 AM
Super User
Posts: 22,820

Re: Add a column to sas file

SAS UE can deal with Excel files and SPSS files without issues. 

 

How are you importing your data? If you're not sure of the code and such and are more familiar with SPSS point and click interface, I recommend using the GUI tasks instead of trying to code. 

 

 

Super Contributor
Posts: 448

Re: Add a column to sas file

Also note that upgrading the VirtualBox from 5.2.6 to 5.2.8 have issues with shared folder. In case if you have problem accessing the local files in SAS UE then downgrade the VirtualBox to 5.2.6. You can find the previous version of Virtual Box here VirtualBox-5.2.6-120293-Win.exe

Thanks,
Suryakiran
☑ This topic is solved.

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

Discussion stats
  • 3 replies
  • 86 views
  • 3 likes
  • 4 in conversation