BookmarkSubscribeRSS Feed
epimph69
Calcite | Level 5

Hello everyone ,

last week I worked with one datasets and I kept the variables that I need and it's ok . Today I need another var in other dataset , :

this is my first data

libname data "X:\blabla \data\";

PROC IMPORT OUT= WORK.myfile

            DATAFILE= "X:\blabla \data\Stata datasets\data1"

            DBMS=STATA REPLACE;

RUN;

   

and I want work with dataset 2, is  it correct the following command ?

libname data "X:\blabla \data\";

PROC IMPORT OUT= WORK.myfile

            DATAFILE= "X:\blabla \data\Stata datasets\data1"

            DBMS=STATA REPLACE;


            DATAFILE= "X:\blabla \data\Stata datasets\data2"

            DBMS=STATA REPLACE;

RUN;




4 REPLIES 4
andreas_lds
Jade | Level 19

You can find the documentation of proc import in Base SAS(R) 9.4 Procedures Guide, Second Edition. If you don't like reading docs simple execute the proc and see what SAS has to say Smiley Wink

ballardw
Super User

I don't know about STATA files but in many cases you can use a FILENAME statement to associate multiple files and read them.

Question: You have one output file and two input, are you wanting to have the data from the two STATA files combined into a single SAS data set?

Tom
Super User Tom
Super User

You want to combine the variable from the new file with the variable from the old file then you want to do some type of merge.

If you have a simple file with a unique id variable then a data step merge will do the trick.

libname data "X:\blabla \data\";

PROC IMPORT OUT= WORK.myfile

            DATAFILE= "X:\blabla \data\Stata datasets\data1"

            DBMS=STATA REPLACE;

RUN;

PROC IMPORT OUT= WORK.myfile2

            DATAFILE= "X:\blabla \data\Stata datasets\data2"

            DBMS=STATA REPLACE;

RUN;


data want;

   merge myfile myfile2;

   by ID ;

run;


epimph69
Calcite | Level 5

thx so much

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
  • 4 replies
  • 917 views
  • 3 likes
  • 4 in conversation